From f87ae2292491cb822190695f168b450e4834850e Mon Sep 17 00:00:00 2001 From: jiangrui1994 <31405035+jiangrui1994@users.noreply.github.com> Date: Thu, 20 Feb 2025 14:26:32 +0800 Subject: [PATCH] Update docker-image.yml --- .github/workflows/docker-image.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index a4f5c12..d3e7408 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -9,10 +9,17 @@ jobs: permissions: contents: read packages: write # 必须授权以推送镜像 + env: + REPO_NAME: ${{ github.repository }} steps: - name: 检出代码 uses: actions/checkout@v4 + - name: 设置小写镜像名称 + run: | + LOWER_NAME=$(echo "$REPO_NAME" | tr '[:upper:]' '[:lower:]') + echo "LOWER_NAME=$LOWER_NAME" >> $GITHUB_ENV + - name: 登录到 GitHub Container Registry uses: docker/login-action@v2 with: @@ -26,6 +33,5 @@ jobs: context: . push: ${{ github.event_name == 'push' }} # 仅推送代码时上传镜像 tags: | - ghcr.io/${{ format('{0}:latest', toLower(github.repository)) }} - ghcr.io/${{ format('{0}:{1}', toLower(github.repository), github.sha) }} - ghcr.io/${{ format('{0}:{1}', toLower(github.repository), github.ref_name) }} + ghcr.io/${{ env.LOWER_NAME }}:latest + ghcr.io/${{ env.LOWER_NAME }}:${{ github.sha }}