File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99 type : string
1010
1111permissions :
12- contents : write # 允许推送标签
12+ contents : read # 只需要读权限,推送使用 PAT
1313
1414jobs :
1515 create-tag :
1616 runs-on : ubuntu-latest
1717 steps :
18+ # 关键修改:使用 PAT 来 checkout,后续的 push 才能生效
1819 - name : Checkout repository
1920 uses : actions/checkout@v4
2021 with :
21- fetch-depth : 0 # 获取所有历史,用于检查标签是否已存在
22+ fetch-depth : 0
23+ token : ${{ secrets.PAT_FOR_TAG }} # <--- 使用我们刚配置的 secret
2224
2325 - name : Validate tag format
2426 run : |
@@ -36,14 +38,13 @@ jobs:
3638 echo "❌ Tag $TAG already exists locally."
3739 exit 1
3840 fi
39- # 检查远程是否存在(可选,但建议)
4041 if git ls-remote --tags origin "$TAG" | grep -q "refs/tags/$TAG"; then
4142 echo "❌ Tag $TAG already exists on remote."
4243 exit 1
4344 fi
4445 echo "✅ Tag does not exist."
4546
46- - name : Create and push tag
47+ - name : Create and push tag using PAT
4748 run : |
4849 TAG="${{ github.event.inputs.tag_name }}"
4950 git config user.name "github-actions[bot]"
5354 echo "🚀 Tag $TAG created and pushed successfully."
5455
5556 - name : Done
56- run : echo "The tag will now trigger the 'install' workflow automatically."
57+ run : echo "The tag has been pushed and should trigger the 'install' workflow automatically."
You can’t perform that action at this time.
0 commit comments