From e57137b101e187ea8eee4ebc08a7c4835718befc Mon Sep 17 00:00:00 2001 From: hrz <1710360675@qq.com> Date: Sun, 6 Apr 2025 11:50:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=A6=82=E6=9E=9C=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E4=B8=8D=E5=88=B0=E7=89=88=E6=9C=AC=E5=8F=B7=EF=BC=8Cactions?= =?UTF-8?q?=E7=BC=96=E8=AF=91=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * update:更新版本号 * update:允许actions编译手动触发 * fix:如果获取不到版本号,actions编译失败 --- .github/workflows/docker-image.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 611e5e66..42a58dbe 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -42,7 +42,13 @@ jobs: - name: Extract version from tag id: get_version run: | - echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + if [[ "$GITHUB_REF" =~ ^refs/tags/v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then + echo "VERSION=${BASH_REMATCH[1]}" >> $GITHUB_ENV + echo "IS_VERSION=true" >> $GITHUB_ENV + else + echo "VERSION=latest" >> $GITHUB_ENV + echo "IS_VERSION=false" >> $GITHUB_ENV + fi # 构建 xiaozhi-server 镜像 - name: Build and push xiaozhi-server @@ -52,8 +58,7 @@ jobs: file: Dockerfile-server push: true tags: | - ghcr.io/${{ github.repository }}:server_${{ env.VERSION }} - ghcr.io/${{ github.repository }}:server_latest + ${{ env.IS_VERSION == 'true' && format('ghcr.io/{0}:server_{1}\nghcr.io/{0}:server_latest', github.repository, env.VERSION) || format('ghcr.io/{0}:server_latest', github.repository) }} platforms: linux/amd64,linux/arm64 # 构建 manager-api 镜像 @@ -64,6 +69,5 @@ jobs: file: Dockerfile-web push: true tags: | - ghcr.io/${{ github.repository }}:web_${{ env.VERSION }} - ghcr.io/${{ github.repository }}:web_latest + ${{ env.IS_VERSION == 'true' && format('ghcr.io/{0}:web_{1}\nghcr.io/{0}:web_latest', github.repository, env.VERSION) || format('ghcr.io/{0}:web_latest', github.repository) }} platforms: linux/amd64,linux/arm64 \ No newline at end of file