Skip to content

Commit 92ca7a1

Browse files
ci: 更新 create-tag
1 parent 3dde7b1 commit 92ca7a1

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

.github/workflows/create-tag.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,18 @@ on:
99
type: string
1010

1111
permissions:
12-
contents: write # 允许推送标签
12+
contents: read # 只需要读权限,推送使用 PAT
1313

1414
jobs:
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]"
@@ -53,4 +54,4 @@ jobs:
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."

0 commit comments

Comments
 (0)