@@ -2,18 +2,15 @@ name: Build / Test / Push
22
33on :
44 push :
5- workflow_call :
5+ branches :
6+ - ' *'
67 workflow_dispatch :
78
8- env :
9- COMPOSE_FILE : docker-compose.yml:docker-compose.ci.yml
10- DOCKER_METADATA_SET_OUTPUT_ENV : ' true'
11-
129jobs :
1310 build :
1411 runs-on : ubuntu-latest
1512 outputs :
16- image : ${{ steps.meta.outputs.tags }}
13+ build- image : ${{ steps.build- meta.outputs.tags }}
1714 steps :
1815 - name : Checkout code
1916 uses : actions/checkout@v4
@@ -31,20 +28,19 @@ jobs:
3128 username : ${{ github.actor }}
3229 password : ${{ secrets.GITHUB_TOKEN }}
3330
34- - name : Produce image tag 'sha-*-pre'
35- id : meta
31+ - name : Produce the build image tag
32+ id : build- meta
3633 uses : docker/metadata-action@v5
3734 with :
3835 images : ghcr.io/${{ github.repository }}
39- tags : type=sha,suffix=-pre
36+ tags : type=sha,suffix=-build-${{ github.run_id }}_${{ github.run_attempt }}
4037
4138 - name : Build and push the untested image
42- id : build
4339 uses : docker/build-push-action@v6
4440 with :
4541 push : true
46- labels : ${{ steps.meta.outputs.labels }}
47- tags : ${{ steps.meta.outputs.tags }}
42+ labels : ${{ steps.build- meta.outputs.labels }}
43+ tags : ${{ steps.build- meta.outputs.tags }}
4844 provenance : true
4945 cache-from : type=gha
5046 cache-to : type=gha
5450 needs :
5551 - build
5652 env :
57- DOCKER_APP_IMAGE : ${{ needs.build.outputs.image }}
53+ DOCKER_APP_IMAGE : ${{ needs.build.outputs.build- image }}
5854 steps :
5955 - name : Checkout code
6056 uses : actions/checkout@v4
@@ -74,10 +70,40 @@ jobs:
7470
7571 - name : Run the tests
7672 run : bin/test
73+ env :
74+ COMPOSE_FILE : docker-compose.yml:docker-compose.ci.yml
75+
76+ push :
77+ runs-on : ubuntu-latest
78+ needs :
79+ - build
80+ - test
81+ steps :
82+ - name : Checkout code
83+ uses : actions/checkout@v4
84+
85+ - name : Login to GitHub Container Registry
86+ uses : docker/login-action@v3
87+ with :
88+ registry : ghcr.io
89+ username : ${{ github.actor }}
90+ password : ${{ secrets.GITHUB_TOKEN }}
91+
92+ - name : Produce permanent image tags
93+ id : branch-meta
94+ uses : docker/metadata-action@v5
95+ with :
96+ images : ghcr.io/${{ github.repository }}
97+ tags : |
98+ type=sha
99+ type=ref,event=branch
100+ type=raw,value=latest,enable={{is_default_branch}}
77101
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}}
102+ - name : Retag and push the image
103+ uses : docker/build-push-action@v6
104+ with :
105+ push : true
106+ labels : ${{ steps.branch-meta.outputs.labels }}
107+ tags : ${{ steps.branch-meta.outputs.tags }}
108+ provenance : true
109+ cache-from : type=registry,ref=${{ needs.build.outputs.build-image }}
0 commit comments