1919 strategy :
2020 fail-fast : false
2121 matrix :
22- runner :
23- - ubuntu-24.04
24- - ubuntu-24.04-arm
22+ include :
23+ - platform : linux/amd64
24+ runner : ubuntu-24.04
25+ - platform : linux/arm64
26+ runner : ubuntu-24.04-arm
2527 steps :
2628 - name : Checkout code
2729 uses : actions/checkout@v4
@@ -37,15 +39,15 @@ jobs:
3739 password : ${{ secrets.GITHUB_TOKEN }}
3840
3941 - id : build-meta
40- name : Docker meta
42+ name : Prepare Docker metadata
4143 uses : docker/metadata-action@v5
4244 with :
4345 images : ghcr.io/${{ github.repository }}
4446 tags : type=sha,suffix=${{ env.BUILD_SUFFIX }}
4547
4648 # Build cache is shared among all builds of the same architecture
4749 - id : cache-meta
48- name : Docker meta
50+ name : Fetch build cache metadata
4951 uses : docker/metadata-action@v5
5052 with :
5153 images : ghcr.io/${{ github.repository }}
6062 name : Build/push the arch-specific image
6163 uses : docker/build-push-action@v6
6264 with :
65+ platforms : ${{ matrix.platform }}
6366 cache-from : type=registry,ref=${{ steps.cache-meta.outputs.tags }}
6467 cache-to : type=registry,ref=${{ steps.cache-meta.outputs.tags }},mode=max
6568 labels : ${{ steps.build-meta.outputs.labels }}
@@ -74,13 +77,15 @@ jobs:
7477 echo "image-${RUNNER_ARCH,,}=${{ steps.get-registry.outputs.registry }}@${{ steps.build.outputs.digest }}" | tee -a "$GITHUB_OUTPUT"
7578
7679 merge :
77- runs-on : ubuntu-24.04
80+ runs-on : ubuntu-latest
7881 needs : build
7982 env :
8083 DOCKER_APP_IMAGE_ARM64 : ${{ needs.build.outputs.image-arm64 }}
8184 DOCKER_APP_IMAGE_X64 : ${{ needs.build.outputs.image-x64 }}
8285 outputs :
8386 image : ${{ steps.meta.outputs.tags }}
87+ build-image-arm64 : ${{ needs.build.outputs.image-arm64 }}
88+ build-image-x64 : ${{ needs.build.outputs.image-x64 }}
8489 steps :
8590 - name : Checkout code
8691 uses : actions/checkout@v4
@@ -100,7 +105,8 @@ jobs:
100105 uses : docker/metadata-action@v5
101106 with :
102107 images : ghcr.io/${{ github.repository }}
103- tags : type=sha,suffix=${{ env.BUILD_SUFFIX }}
108+ tags : |
109+ type=sha,suffix=-build-${{ github.run_id }}_${{ github.run_attempt }}
104110
105111 - name : Push the multi-platform app image
106112 run : |
@@ -109,7 +115,7 @@ jobs:
109115 "$DOCKER_APP_IMAGE_ARM64" "$DOCKER_APP_IMAGE_X64"
110116
111117 test :
112- runs-on : ubuntu-24.04
118+ runs-on : ubuntu-latest
113119 needs : merge
114120 env :
115121 COMPOSE_FILE : docker-compose.yml:docker-compose.ci.yml
@@ -164,16 +170,20 @@ jobs:
164170 if-no-files-found : error
165171
166172 push :
167- runs-on : ubuntu-24.04
173+ runs-on : ubuntu-latest
168174 needs :
169175 - merge
170176 - test
171177 env :
172178 DOCKER_APP_IMAGE : ${{ needs.merge.outputs.image }}
179+ DOCKER_APP_IMAGE_ARM64 : ${{ needs.merge.outputs.build-image-arm64 }}
180+ DOCKER_APP_IMAGE_X64 : ${{ needs.merge.outputs.build-image-x64 }}
173181 steps :
174182 - name : Checkout code
175183 uses : actions/checkout@v4
176184
185+ - name : Set up Docker Buildx
186+ uses : docker/setup-buildx-action@v3
177187 - name : Login to GitHub Container Registry
178188 uses : docker/login-action@v3
179189 with :
@@ -192,6 +202,5 @@ jobs:
192202
193203 - name : Retag and push the image
194204 run : |
195- docker pull "$DOCKER_APP_IMAGE"
196- echo "$DOCKER_METADATA_OUTPUT_TAGS" | tr ' ' '\n' | xargs -n1 docker tag "$DOCKER_APP_IMAGE"
197- docker push --all-tags "$(echo "$DOCKER_APP_IMAGE" | cut -f1 -d:)"
205+ docker buildx imagetools create \
206+ $(jq -cr '.tags | map("--tag " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") $DOCKER_APP_IMAGE_ARM64 $DOCKER_APP_IMAGE_X64
0 commit comments