fix(workflow): 修复自动标签工作流中的重复标签问题

- 添加了对现有标签的检查以避免重复创建
- 配置了从正确的提交哈希进行检出
- 在推送标签前验证标签是否已存在
- 添加了标签已存在时的优雅退出机制
- 确保了 Git 配置的一致性设置
This commit is contained in:
GeWuYou 2026-01-29 12:23:07 +08:00
parent ef655bbaf1
commit 9b77aa4b07

View File

@ -25,8 +25,9 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.workflow_run.head_sha }}
persist-credentials: false
- name: Check for skip keyword
id: check_skip
run: |
@ -54,7 +55,14 @@ jobs:
PAT: ${{ secrets.PAT_TOKEN }}
TAG: ${{ steps.version.outputs.new_tag }}
run: |
set -e
git config user.name "GitHub Action"
git config user.email "action@github.com"
if git show-ref --tags --verify --quiet "refs/tags/$TAG"; then
echo "Tag $TAG already exists, skipping"
exit 0
fi
git tag -a "$TAG" -m "Auto tag $TAG"
git push "https://x-access-token:${PAT}@github.com/${{ github.repository }}.git" "$TAG"
git push "https://x-access-token:${PAT}@github.com/${{ github.repository }}.git" "$TAG"