From 75c6fe99171da3f4e8cdf699b1ea886e19feff02 Mon Sep 17 00:00:00 2001 From: Aparencia Date: Thu, 30 Jul 2026 09:36:08 +0800 Subject: [PATCH] =?UTF-8?q?fix(ci):=20=E5=8F=91=E7=89=88=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?=E6=B5=81=E6=94=B9=E7=94=A8=20RELEASE=5FTOKEN=20=E4=BB=A5?= =?UTF-8?q?=E7=BB=95=E8=BF=87=20main=20=E5=88=86=E6=94=AF=E4=BF=9D?= =?UTF-8?q?=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 前两次 Version & Release 均失败于 GH013:main 的 ruleset 强制 "Changes must be made through a pull request",把 semantic-release 自身的发版推送(chore(release) 提交 + CHANGELOG + tag → HEAD:main) 一并拦截。 修复:checkout 与 semantic-release 环境改用 secrets.RELEASE_TOKEN (细粒度 PAT,Contents:RW,持有者为仓库 admin),配合 ruleset Bypass list(Repository admin)实现发版链路的受控绕过; 未配置该 secret 时回退内置 token,行为与现状一致(不劣化)。 需要仓库侧配套(手工步骤): 1) 创建细粒度 PAT(仅 Entropydecrease 仓库,Contents: Read and write) 2) 仓库 Settings → Secrets → Actions 新建 RELEASE_TOKEN 3) main-protection ruleset → Bypass list 添加 Repository admin --- .github/workflows/version-release.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/version-release.yml b/.github/workflows/version-release.yml index 03ab5ff9..3c419262 100644 --- a/.github/workflows/version-release.yml +++ b/.github/workflows/version-release.yml @@ -31,6 +31,10 @@ jobs: with: fetch-depth: 0 persist-credentials: true + # RELEASE_TOKEN:细粒度 PAT(Contents:RW),持有者为仓库 admin, + # 配合 ruleset Bypass list(Repository admin)绕过 main 的 PR 强制规则; + # 未配置该 secret 时回退内置 token(checkout 可用,push 仍会被规则拦截) + token: ${{ secrets.RELEASE_TOKEN || github.token }} - name: Setup Node uses: actions/setup-node@v4 @@ -42,5 +46,6 @@ jobs: - name: Semantic Release env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # 同上:semantic-release 的 git push 与 GitHub Release 创建均使用 PAT + GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN || secrets.GITHUB_TOKEN }} run: npx semantic-release