1313
1414jobs :
1515 build :
16- runs-on : ubuntu-latest
16+ runs-on : ${{ matrix.runner }}
17+ strategy :
18+ matrix :
19+ include :
20+ - platform : linux/amd64
21+ runner : ubuntu-latest
22+ - platform : linux/arm64
23+ runner : ubuntu-24.04-arm
1724 permissions :
1825 contents : read
1926 packages : write
2027
2128 steps :
2229 - uses : actions/checkout@v4
2330
24- - uses : docker/setup-qemu-action@v3
25-
2631 - uses : docker/setup-buildx-action@v3
2732
2833 - uses : docker/login-action@v3
3237 username : ${{ github.actor }}
3338 password : ${{ secrets.GITHUB_TOKEN }}
3439
40+ - uses : docker/metadata-action@v5
41+ id : meta
42+ with :
43+ images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
44+
45+ - uses : docker/build-push-action@v6
46+ id : build
47+ with :
48+ context : .
49+ platforms : ${{ matrix.platform }}
50+ labels : ${{ steps.meta.outputs.labels }}
51+ outputs : type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }}
52+ cache-from : type=gha,scope=${{ matrix.platform }}
53+ cache-to : type=gha,mode=max,scope=${{ matrix.platform }}
54+
55+ - name : Export digest
56+ if : github.event_name != 'pull_request'
57+ run : |
58+ mkdir -p /tmp/digests
59+ digest="${{ steps.build.outputs.digest }}"
60+ touch "/tmp/digests/${digest#sha256:}"
61+
62+ - name : Upload digest
63+ if : github.event_name != 'pull_request'
64+ uses : actions/upload-artifact@v4
65+ with :
66+ name : digests-${{ matrix.runner }}
67+ path : /tmp/digests/*
68+ if-no-files-found : error
69+ retention-days : 1
70+
71+ merge :
72+ runs-on : ubuntu-latest
73+ if : github.event_name != 'pull_request'
74+ needs : build
75+ permissions :
76+ contents : read
77+ packages : write
78+
79+ steps :
80+ - name : Download digests
81+ uses : actions/download-artifact@v4
82+ with :
83+ path : /tmp/digests
84+ pattern : digests-*
85+ merge-multiple : true
86+
87+ - uses : docker/setup-buildx-action@v3
88+
89+ - uses : docker/login-action@v3
90+ with :
91+ registry : ${{ env.REGISTRY }}
92+ username : ${{ github.actor }}
93+ password : ${{ secrets.GITHUB_TOKEN }}
94+
3595 - uses : docker/metadata-action@v5
3696 id : meta
3797 with :
@@ -42,12 +102,9 @@ jobs:
42102 type=semver,pattern={{major}}.{{minor}}
43103 type=sha
44104
45- - uses : docker/build-push-action@v6
46- with :
47- context : .
48- platforms : linux/amd64,linux/arm64
49- push : ${{ github.event_name != 'pull_request' }}
50- tags : ${{ steps.meta.outputs.tags }}
51- labels : ${{ steps.meta.outputs.labels }}
52- cache-from : type=gha
53- cache-to : type=gha,mode=max
105+ - name : Create manifest list and push
106+ working-directory : /tmp/digests
107+ run : |
108+ docker buildx imagetools create \
109+ $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
110+ $(printf '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *)
0 commit comments