Skip to content

Commit 36fcdc0

Browse files
ci: changeset version update (#1874)
* ci: pass GITHUB_TOKEN to changeset version in snapshot/pr jobs changeset version uses @changesets/changelog-github, which calls the GitHub API to build changelog entries. Without GITHUB_TOKEN it fails once committed changesets are present on the merge ref. The release path already sets the token; the snapshot and pr jobs did not. * ci: scope publish workflow permissions per job Replace the broad workflow-level token grant (contents/pull-requests/ id-token: write) with a read-only default, and opt each job up to only what it uses: release keeps contents+id-token write, snapshot drops to read+id-token, pr gets read+id-token+pull-requests, pre-run gets actions: write for cancel-previous. Limits the token exposed to untrusted PR/branch code in the snapshot and pr jobs.
1 parent 1098749 commit 36fcdc0

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

‎.github/workflows/publish.yml‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,17 @@ on:
5858
default: ''
5959

6060
permissions:
61-
contents: write
62-
pull-requests: write
63-
id-token: write # npm OIDC trusted publishing
61+
contents: read
6462

6563
concurrency: ${{ github.workflow }}-${{ github.ref }}
6664

6765
jobs:
6866
pre-run:
6967
uses: ./.github/workflows/pre-run.yml
7068
secrets: inherit
69+
permissions:
70+
contents: read
71+
actions: write # cancel-previous-runs
7172

7273
# Classify the dispatch `target` input into a `kind`:
7374
# release — empty target (manual production publish)
@@ -113,6 +114,9 @@ jobs:
113114
release:
114115
runs-on: ubuntu-latest
115116
needs: [pre-run, validate-dispatch]
117+
permissions:
118+
contents: write # push git tags + create GitHub Releases
119+
id-token: write # npm OIDC trusted publishing
116120
# `!failure() && !cancelled()` lets this job run when `validate-dispatch`
117121
# is `skipped` (push trigger), but still blocks on a real failure of
118122
# `pre-run` or `validate-dispatch`. `ref_name == 'main'` keeps manual
@@ -149,6 +153,9 @@ jobs:
149153
runs-on: ubuntu-latest
150154
needs: [pre-run, validate-dispatch]
151155
if: "needs.pre-run.outputs.is-not-fork == 'true' && needs.validate-dispatch.outputs.kind == 'snapshot'"
156+
permissions:
157+
contents: read
158+
id-token: write # npm OIDC trusted publishing
152159
steps:
153160
# Map target → (ref to publish from, dist-tag to publish under).
154161
# `main` is the canonical beta channel, so it gets the `beta` tag.
@@ -190,6 +197,8 @@ jobs:
190197
fi
191198
192199
- run: npx changeset version
200+
env:
201+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
193202
- run: node .github/scripts/snapshot-version.mjs ${{ steps.target.outputs.tag }}
194203

195204
- name: Build packages
@@ -210,6 +219,10 @@ jobs:
210219
runs-on: ubuntu-latest
211220
needs: [pre-run, validate-dispatch]
212221
if: "needs.pre-run.outputs.is-not-fork == 'true' && needs.validate-dispatch.outputs.kind == 'pr'"
222+
permissions:
223+
contents: read
224+
id-token: write # npm OIDC trusted publishing
225+
pull-requests: write # update PR sticky header
213226
steps:
214227
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
215228
with:
@@ -236,6 +249,8 @@ jobs:
236249
fi
237250
238251
- run: npx changeset version
252+
env:
253+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
239254
- id: snapshot
240255
run: node .github/scripts/snapshot-version.mjs pr --pr ${{ inputs.target }}
241256

0 commit comments

Comments
 (0)