1212jobs :
1313 build :
1414 runs-on : ubuntu-latest
15+ outputs :
16+ imageid : ${{ steps.build.outputs.imageid }}
1517 steps :
1618 - name : Checkout code
1719 uses : actions/checkout@v4
@@ -22,46 +24,60 @@ jobs:
2224 - name : Set up Docker Buildx
2325 uses : docker/setup-buildx-action@v3
2426
25- - name : Set up Docker Compose
26- uses : docker/setup-compose-action@v1
27-
2827 - name : Login to GitHub Container Registry
2928 uses : docker/login-action@v3
3029 with :
3130 registry : ghcr.io
3231 username : ${{ github.actor }}
3332 password : ${{ secrets.GITHUB_TOKEN }}
3433
35- - name : Produce image metadata
34+ - name : Produce image tag 'sha-*-pre'
3635 id : meta
3736 uses : docker/metadata-action@v5
3837 with :
3938 images : ghcr.io/${{ github.repository }}
40- tags : |
41- type=sha
42- type=ref,event=branch
43- type=ref,event=tag
44- type=semver,pattern={{major}}
45- type=semver,pattern={{major}}.{{minor}}
46- type=semver,pattern={{version}}
47- type=raw,value=latest,enable={{is_default_branch}}
39+ tags : type=sha,suffix=-pre
4840
49- - name : Fetch the sha-based image tag
50- run : echo "$DOCKER_METADATA_OUTPUT_TAGS" | grep -m1 ':sha-' | xargs | sed 's/^/DOCKER_APP_IMAGE=/' >> $GITHUB_ENV
51-
52- - name : Build the image
41+ - name : Build and push the untested image
5342 id : build
5443 uses : docker/build-push-action@v6
5544 with :
56- push : false
45+ push : true
5746 labels : ${{ steps.meta.outputs.labels }}
5847 tags : ${{ steps.meta.outputs.tags }}
5948 provenance : true
6049 cache-from : type=gha
6150 cache-to : type=gha
6251
52+ test :
53+ runs-on : ubuntu-latest
54+ needs :
55+ - build
56+ env :
57+ DOCKER_APP_IMAGE : ${{ needs.build.outputs.imageid }}
58+ steps :
59+ - name : Checkout code
60+ uses : actions/checkout@v4
61+
62+ - name : Set up QEMU
63+ uses : docker/setup-qemu-action@v3
64+
65+ - name : Set up Docker Compose
66+ uses : docker/setup-compose-action@v1
67+
68+ - name : Login to GitHub Container Registry
69+ uses : docker/login-action@v3
70+ with :
71+ registry : ghcr.io
72+ username : ${{ github.actor }}
73+ password : ${{ secrets.GITHUB_TOKEN }}
74+
6375 - name : Run the tests
6476 run : bin/test
6577
66- - name : Push images
67- run : docker push -a "$DOCKER_APP_IMAGE"
78+ # type=ref,event=branch
79+ # type=ref,event=tag
80+ # type=semver,pattern={{major}}
81+ # type=semver,pattern={{major}}.{{minor}}
82+ # type=semver,pattern={{version}}
83+ # type=raw,value=latest,enable={{is_default_branch}}
0 commit comments