Update docker-image.yml

This commit is contained in:
jiangrui1994
2025-02-20 14:26:32 +08:00
committed by GitHub
parent 868d99367d
commit f87ae22924

View File

@@ -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 }}