优化镜像构建yml (#258)

* 优化镜像构建yml

* 继续优化镜像构建
This commit is contained in:
huangxd- authored and GitHub committed 2026-03-28 00:04:07 +08:00
1 parent ba88bc03a5
commit b4511e501e
1 file changed
+13 -8
+13 -8
View File
@@ -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 \