9
9
jobs :
10
10
docker-hub :
11
11
runs-on : ubuntu-latest
12
+ strategy :
13
+ matrix :
14
+ platform : ["linux/amd64", "linux/arm64"]
12
15
steps :
13
- -
14
- name : Checkout
16
+ - name : Checkout
15
17
uses : actions/checkout@v4
16
- -
17
- name : Login to Docker Hub
18
+
19
+ - name : Set up QEMU # 新增模拟器支持 ARM 架构
20
+ uses : docker/setup-qemu-action@v3
21
+
22
+ - name : Set up Docker Buildx # 启用多架构构建工具链
23
+ uses : docker/setup-buildx-action@v3
24
+
25
+ - name : Login to Docker Hub
18
26
uses : docker/login-action@v3
19
27
with :
20
28
username : xcsoft
21
29
password : ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
22
- -
23
- name : Set up Docker Build Context
24
- uses : docker/setup-buildx-action@v3
25
- -
26
- name : Build and push
30
+
31
+ - name : Build and push
27
32
uses : docker/build-push-action@v5
28
33
with :
29
34
context : .
30
35
file : ./Dockerfile
36
+ platforms : ${{ matrix.platform }} # 动态指定构建平台
31
37
push : true
32
38
tags : |
33
- xcsoft/busuanzi:${{ github.ref_name }}
39
+ xcsoft/busuanzi:${{ github.ref_name }}-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }}
40
+ xcsoft/busuanzi:latest-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }}
34
41
35
42
github-docker :
36
43
runs-on : ubuntu-latest
44
+ strategy : # 同步添加多架构策略
45
+ matrix :
46
+ platform : ["linux/amd64", "linux/arm64"]
37
47
steps :
38
48
- name : Checkout
39
49
uses : actions/checkout@v4
40
50
51
+ - name : Set up QEMU
52
+ uses : docker/setup-qemu-action@v3
53
+
54
+ - name : Set up Docker Buildx
55
+ uses : docker/setup-buildx-action@v3
56
+
41
57
- name : Login to Docker Hub
42
58
if : github.event_name != 'pull_request'
43
59
uses : docker/login-action@v1
@@ -46,15 +62,13 @@ jobs:
46
62
username : ${{ github.actor }}
47
63
password : ${{ secrets.GITHUB_TOKEN }}
48
64
49
- - name : Set up Docker Build Context
50
-
51
- uses : docker/setup-buildx-action@v3
52
-
53
65
- name : Build and push
54
66
uses : docker/build-push-action@v5
55
67
with :
56
68
context : .
57
69
file : ./Dockerfile
70
+ platforms : ${{ matrix.platform }}
58
71
push : true
59
72
tags : |
60
- ghcr.io/soxft/busuanzi:${{ github.ref_name }}
73
+ ghcr.io/soxft/busuanzi:${{ github.ref_name }}-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }}
74
+ ghcr.io/soxft/busuanzi:latest-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }}
0 commit comments