Skip to content

Commit dda6b06

Browse files
committed
fix: use GIT_TOKEN
1 parent 98d5749 commit dda6b06

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

.github/workflows/npm-release.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ name: NPM Trusted Publisher
22

33
on:
44
workflow_call:
5+
secrets:
6+
GIT_TOKEN:
7+
description: 'github personal token'
8+
required: true
59

610
inputs:
711
checkTest:
@@ -55,7 +59,7 @@ jobs:
5559
uses: actions/checkout@v4
5660
with:
5761
path: main_repo
58-
token: ${{ secrets.GITHUB_TOKEN }}
62+
token: ${{ secrets.GIT_TOKEN }}
5963

6064
# Setup Node.js environment
6165
- name: Setup Node.js

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,14 @@ BREAKING CHANGE: Drop Node.js < 18 support
145145

146146
### 配置方式
147147

148+
- 创建 GitHub Token
149+
- 因为生成的 CHANGELOG.md 和 package.json 需回写 GitHub,而默认的 `GITHUB_TOKEN` 没有该权限。如会被保护分支规则拦截。
150+
- 因此需要创建一个新的 Token,参见[文档](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token)
151+
152+
- 配置 Token
153+
- 在项目或组织维度配置 `GIT_TOKEN`
154+
- 参见[文档](https://docs.github.com/en/codespaces/managing-codespaces-for-your-organization/managing-encrypted-secrets-for-your-repository-and-organization-for-github-codespaces)
155+
148156
- 创建 `.github/workflows/release.yml`
149157

150158
```yaml
@@ -160,6 +168,8 @@ jobs:
160168
release:
161169
name: Node.js
162170
uses: node-modules/github-actions/.github/workflows/npm-release.yml@master
171+
secrets:
172+
GIT_TOKEN: ${{ secrets.GIT_TOKEN }}
163173
# with:
164174
# checkTest: false
165175
# dryRun: true

0 commit comments

Comments
 (0)