Skip to content
This repository was archived by the owner on Nov 3, 2025. It is now read-only.

Commit 46c01fe

Browse files
authored
Update docker-build.yml
1 parent b415d4b commit 46c01fe

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

.github/workflows/docker-build.yml

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,6 @@ jobs:
3333
permissions:
3434
contents: read
3535
packages: write
36-
strategy:
37-
matrix:
38-
include:
39-
- platform: linux/amd64
40-
arch: amd64
41-
- platform: linux/arm64
42-
arch: arm64
4336

4437
steps:
4538
- name: 检出代码
@@ -73,21 +66,20 @@ jobs:
7366
type=raw,value=latest,enable={{is_default_branch}}
7467
type=raw,value=${{ github.event.inputs.tag }},enable=${{ github.event_name == 'workflow_dispatch' }}
7568
76-
- name: 构建并推送 Docker 镜像 (${{ matrix.arch }})
77-
if: matrix.arch == 'amd64' || (matrix.arch == 'arm64' && (github.event_name != 'workflow_dispatch' || github.event.inputs.build_arm64 == 'true'))
69+
- name: 构建并推送多架构 Docker 镜像
7870
uses: docker/build-push-action@v5
7971
with:
8072
context: .
81-
file: ${{ matrix.arch == 'arm64' && 'Dockerfile.arm64' || 'Dockerfile' }}
82-
platforms: ${{ matrix.platform }}
73+
file: Dockerfile
74+
platforms: linux/amd64${{ (github.event_name != 'workflow_dispatch' || github.event.inputs.build_arm64 == 'true') && ',linux/arm64' || '' }}
8375
push: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.push_to_registry == 'true' }}
8476
tags: ${{ steps.meta.outputs.tags }}
8577
labels: ${{ steps.meta.outputs.labels }}
86-
cache-from: type=gha,scope=${{ matrix.arch }}
87-
cache-to: type=gha,mode=max,scope=${{ matrix.arch }}
78+
cache-from: type=gha,scope=multi-arch
79+
cache-to: type=gha,mode=max,scope=multi-arch
8880
build-args: |
89-
BUILDPLATFORM=${{ matrix.platform }}
90-
TARGETPLATFORM=${{ matrix.platform }}
81+
BUILDPLATFORM=linux/amd64
82+
TARGETPLATFORM=linux/amd64
9183
outputs: type=registry
9284
provenance: false
9385
sbom: false
@@ -98,7 +90,7 @@ jobs:
9890
echo "## 🐳 Docker 镜像构建完成" >> $GITHUB_STEP_SUMMARY
9991
echo "" >> $GITHUB_STEP_SUMMARY
10092
echo "**触发方式:** ${{ github.event_name }}" >> $GITHUB_STEP_SUMMARY
101-
echo "**构建架构:** ${{ matrix.arch }}" >> $GITHUB_STEP_SUMMARY
93+
echo "**构建架构:** multi-arch (amd64${{ (github.event_name != 'workflow_dispatch' || github.event.inputs.build_arm64 == 'true') && ' + arm64' || '' }})" >> $GITHUB_STEP_SUMMARY
10294
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
10395
echo "**自定义标签:** ${{ github.event.inputs.tag }}" >> $GITHUB_STEP_SUMMARY
10496
echo "**推送到注册表:** ${{ github.event.inputs.push_to_registry }}" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)