1313
1414jobs :
1515 build :
16- runs-on : ubuntu-latest
16+ name : Build ${{ matrix.platform }}
17+ runs-on : ${{ matrix.runner }}
1718 permissions :
1819 contents : read
20+ strategy :
21+ fail-fast : false
22+ matrix :
23+ include :
24+ - arch : amd64
25+ platform : linux/amd64
26+ runner : ubuntu-latest
27+ - arch : arm64
28+ platform : linux/arm64
29+ runner : ubuntu-24.04-arm
1930 steps :
2031 - name : Checkout
2132 uses : actions/checkout@v4
@@ -36,15 +47,55 @@ jobs:
3647 images : ${{ env.IMAGE_NAME }}
3748 tags : |
3849 type=ref,event=tag
39- type=ref,event=branch
50+ type=raw,value=latest,enable={{is_default_branch}}
4051 type=sha
52+ flavor : |
53+ suffix=-${{ matrix.arch }}
4154
42- - name : Build and push
55+ - name : Build and push (${{ matrix.platform }})
4356 uses : docker/build-push-action@v6
4457 with :
4558 context : .
4659 file : ./Dockerfile
4760 push : true
48- platforms : linux/amd64
61+ platforms : ${{ matrix.platform }}
4962 tags : ${{ steps.meta.outputs.tags }}
5063 labels : ${{ steps.meta.outputs.labels }}
64+
65+ manifest :
66+ name : Publish multi-arch manifests
67+ runs-on : ubuntu-latest
68+ needs : build
69+ permissions :
70+ contents : read
71+ steps :
72+ - name : Checkout
73+ uses : actions/checkout@v4
74+
75+ - name : Set up Docker Buildx
76+ uses : docker/setup-buildx-action@v3
77+
78+ - name : Log in to Docker Hub
79+ uses : docker/login-action@v3
80+ with :
81+ username : ${{ secrets.DOCKERHUB_USERNAME }}
82+ password : ${{ secrets.DOCKERHUB_TOKEN }}
83+
84+ - name : Docker metadata
85+ id : meta
86+ uses : docker/metadata-action@v5
87+ with :
88+ images : ${{ env.IMAGE_NAME }}
89+ tags : |
90+ type=ref,event=tag
91+ type=raw,value=latest,enable={{is_default_branch}}
92+ type=sha
93+
94+ - name : Create multi-arch manifests
95+ run : |
96+ while IFS= read -r tag; do
97+ docker buildx imagetools create \
98+ -t "$tag" \
99+ "$tag-amd64" \
100+ "$tag-arm64"
101+ done <<< "${{ steps.meta.outputs.tags }}"
0 commit comments