1 parent
ba88bc03a5
commit
b4511e501e
1 file changed
+13
-8
@@ -32,20 +32,25 @@ jobs:
|
||||
else
|
||||
echo "VERSION_TAG=${{ env.VERSION }}" >> $GITHUB_ENV
|
||||
fi
|
||||
# 设置 Docker 镜像缓存(可选,加速构建)
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
# 登录 Docker Hub
|
||||
# ✅ 先登录,再初始化 Buildx,避免拉取 BuildKit 镜像时触发匿名限速
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v2
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
# 构建 Docker 镜像,并指定平台为 amd64 和 arm64,推送到 Docker Hub
|
||||
# 使用单条命令同时指定两个标签,避免重复构建
|
||||
- name: Build and Push Docker image with version and latest tag
|
||||
# 登录后手动拉取,绕过匿名限速
|
||||
- name: Pull BuildKit image
|
||||
run: docker pull moby/buildkit:buildx-stable-1
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Build and Push Docker image
|
||||
run: |
|
||||
if [ "${{ github.ref }}" = "refs/heads/main" ]; then
|
||||
docker buildx build --platform linux/amd64,linux/arm64 \
|
||||
|
||||
Reference in new issue
Block a user