1+ name : Build and Push Docker Image
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+
8+ permissions :
9+ contents : read
10+ packages : write
11+
12+ jobs :
13+ build-amd64 :
14+ runs-on : runs-on=${{ github.run_id }}/runner=4cpu-linux-x64
15+
16+ steps :
17+ - name : Checkout code
18+ uses : actions/checkout@v4
19+
20+ - name : Set up Docker Buildx
21+ uses : docker/setup-buildx-action@v3
22+
23+ - name : Login to GitHub Container Registry
24+ uses : docker/login-action@v3
25+ with :
26+ registry : ghcr.io
27+ username : ${{ github.repository_owner }}
28+ password : ${{ secrets.GITHUB_TOKEN }}
29+
30+ - name : Build and push (AMD64)
31+ uses : docker/build-push-action@v6
32+ with :
33+ platforms : linux/amd64
34+ context : .
35+ push : true
36+ tags : |
37+ ghcr.io/${{ github.repository }}:latest-amd
38+ ghcr.io/${{ github.repository }}:${{ github.sha }}-amd
39+
40+ build-arm64 :
41+ runs-on : runs-on=${{ github.run_id }}/runner=4cpu-linux-arm64
42+
43+ steps :
44+ - name : Checkout code
45+ uses : actions/checkout@v4
46+
47+ - name : Set up Docker Buildx
48+ uses : docker/setup-buildx-action@v3
49+
50+ - name : Login to GitHub Container Registry
51+ uses : docker/login-action@v3
52+ with :
53+ registry : ghcr.io
54+ username : ${{ github.repository_owner }}
55+ password : ${{ secrets.GITHUB_TOKEN }}
56+
57+ - name : Build and push (ARM64)
58+ uses : docker/build-push-action@v6
59+ with :
60+ platforms : linux/arm64
61+ context : .
62+ push : true
63+ tags : |
64+ ghcr.io/${{ github.repository }}:latest-arm
65+ ghcr.io/${{ github.repository }}:${{ github.sha }}-arm
66+
67+ build-merge :
68+ runs-on : ubuntu-latest
69+
70+ needs :
71+ - build-amd64
72+ - build-arm64
73+
74+ steps :
75+ - name : Set up Docker Buildx
76+ uses : docker/setup-buildx-action@v3
77+
78+ - name : Login to GHCR
79+ uses : docker/login-action@v3
80+ with :
81+ registry : ghcr.io
82+ username : ${{ github.repository_owner }}
83+ password : ${{ secrets.GITHUB_TOKEN }}
84+
85+ - name : Merge
86+ run : |
87+ docker buildx imagetools create -t ghcr.io/${{ github.repository }}:latest \
88+ ghcr.io/${{ github.repository }}:latest-amd \
89+ ghcr.io/${{ github.repository }}:latest-arm
0 commit comments