Skip to content

Commit bd62aa4

Browse files
committed
fix(ci): pass App token to checkout so the persisted git credential is App-authored
Copilot caught a real gap in the previous commit on this PR: setting `env.GITHUB_TOKEN` for changesets/action only affects the action's Octokit calls (PR creation, etc.). The actual `git push origin changeset-release/main` that changesets/action performs uses **git's persisted remote credential**, not the env var. `actions/checkout@v6` persists `secrets.GITHUB_TOKEN` into git config by default, so the push was still GITHUB_TOKEN- authored — the workflow-trigger suppression we were trying to bypass would have continued to bite. Fix: - Mint the App token *before* checkout (was: after `pnpm build`). - Pass it to checkout via `token: ${{ steps.app-token.outputs.token }}`, so the persisted credential is the App token's. - changesets/action's `env.GITHUB_TOKEN` stays on the App token (it was already correct; this just makes the push credential align with the API credential). Side-effect: the trailing "Update floating v<major> tag" step now also pushes under the App identity (because it uses the same persisted git credential). That's fine — the App has `Contents: write`, and the tag push doesn't trigger any workflow we care about, so the broader-permission credential changes nothing functional there.
1 parent 267ea4b commit bd62aa4

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

.github/workflows/release.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,21 @@ jobs:
1919
runs-on: ubuntu-latest
2020
environment: npm-publish
2121
steps:
22+
- uses: actions/create-github-app-token@v1
23+
id: app-token
24+
with:
25+
app-id: ${{ secrets.RELEASE_APP_ID }}
26+
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
27+
# Pass the App token to checkout so the credential persisted into git
28+
# config is the App's, not the default GITHUB_TOKEN. `git push` from
29+
# changesets/action (and from later steps in this job) is then
30+
# App-authored, which triggers downstream workflows. Setting env
31+
# GITHUB_TOKEN alone is not enough — checkout's persisted credential is
32+
# what `git push` actually uses.
2233
- uses: actions/checkout@v6
2334
with:
2435
fetch-depth: 0
36+
token: ${{ steps.app-token.outputs.token }}
2537
- uses: pnpm/action-setup@v6
2638
- uses: actions/setup-node@v6
2739
with:
@@ -32,11 +44,6 @@ jobs:
3244
- run: npm install -g npm@latest
3345
- run: pnpm install --frozen-lockfile
3446
- run: pnpm build
35-
- uses: actions/create-github-app-token@v1
36-
id: app-token
37-
with:
38-
app-id: ${{ secrets.RELEASE_APP_ID }}
39-
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
4047
- name: Create release PR or publish
4148
id: changesets
4249
uses: changesets/action@v1

0 commit comments

Comments
 (0)