-
Notifications
You must be signed in to change notification settings - Fork 10
85 lines (73 loc) · 2.88 KB
/
build.yml
File metadata and controls
85 lines (73 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: Build, test, and publish container image
on:
# Run pull requests against the default branch
pull_request:
branches: [master]
# Run on push to default branch
push:
branches: [master]
# Run when a release is created
release:
types: [released]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Clone this git repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- name: Docker meta
if: github.event_name != 'pull_request'
id: meta
uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804
with:
# list of Docker images to use as base name for tags
images: |
plus3it/tardigrade-ci
ghcr.io/plus3it/tardigrade-ci
flavor: |
latest=false
# generate Docker tags based on the following events/attributes
tags: |
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
# set version tags for releases
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/0.') }}
- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2
- name: Build and export
uses: docker/build-push-action@1dc73863535b631f98b2378be8619f83b136f4a0
with:
context: .
load: true
tags: plus3it/tardigrade-ci:test
secrets: |
"GITHUB_ACCESS_TOKEN=${{ secrets.GITHUB_TOKEN }}"
- name: Run bats tests
if: github.event_name == 'pull_request'
run: docker run --rm -e "GITHUB_ACCESS_TOKEN=${{ secrets.GITHUB_TOKEN }}" plus3it/tardigrade-ci:test bats/test
- name: Push to registries
if: github.event_name != 'pull_request'
uses: docker/build-push-action@1dc73863535b631f98b2378be8619f83b136f4a0
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
secrets: |
"GITHUB_ACCESS_TOKEN=${{ secrets.GH_READONLY_TOKEN }}"