Skip to content

fix(ci): keep the release token out of .git/config while npm ci runs - #904

Merged
HugoXK merged 1 commit into
mainfrom
dev2/861-release-npm-token
Nov 16, 2026
Merged

HugoXK merged 1 commit into
mainfrom
dev2/861-release-npm-token

Conversation

@HugoXK

@HugoXK HugoXK commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

Written-by: HugoXK
Author: Fledge Platform Dev-2

Fixes #861

What changed

The release publish job holds contents: write, packages: write, id-token: write and attestations: write, and it runs npm ci against the tag. actions/checkout writes the workflow token into .git/config unless told not to, so a dependency lifecycle script running during that install could read a token with publish permissions.

  • .github/workflows/release.yml — the checkout that feeds npm ci now sets persist-credentials: false. Nothing else in the job relied on the persisted copy: the provenance step already passes secrets.GITHUB_TOKEN explicitly as GH_TOKEN, so the only user of the credential store was the implicit one.
  • test/releasePublishToken.test.ts — the red test. It reads release.yml as text (the same way test/ciConcurrency.test.ts reads ci.yml) and requires every job that holds contents: write and runs npm ci to have persist-credentials: false on its checkout. A job this helper cannot see fails instead of passing quietly.
  • docs/autonomous-dev.md — one paragraph on the release job's token handling, next to the existing release.yml description.
  • changelog.d/861-release-publish-token.security.md — the fragment.

Not changed, deliberately: the workflow permissions stay as they are (the publish needs them), and no npm ci --ignore-scripts was added — the vendor's lockfile scripts are part of a normal install, and the fix belongs where the credential is, not where the script runs.

Ran:

  • npx tsx --test test/releasePublishToken.test.ts at base 3672754c and at the tip 28ac4cd899c13525141a7312eff113cb1a94acb2: 1 fail / 0 pass before the change (the checkout had no persist-credentials), 1 pass / 0 fail after.
  • npm run check on the tip's tree: exit 0 — lint clean, tsc --noEmit clean, 2405 tests / 2405 pass / 0 fail, build clean.
  • node scripts/changelog.mjs check — 23 fragment(s) ok.

Not run:

  • A real tag publish: that pushes an image and a release, so it is the owner's action. The change is a with: key read by the workflow file, and the new test is the check that runs in CI.
  • npm run dev — no user-visible surface changes.

Risk and rollback

T3 by path (.github/**); risk-gate has the last word. The blast radius is the release job only, and the change removes a credential rather than adding reach. Rollback is one line: delete persist-credentials: false. If a later step turns out to need the persisted credential, the failure is an explicit auth error at tag time, not a silent one.

Docs

docs/autonomous-dev.md updated in this PR — the release job's token handling is stated beside the job description. Fragments: one, changelog.d/861-release-publish-token.security.md.

…861)

The publish job holds contents/packages/id-token/attestations write and runs
`npm ci` against the tag. actions/checkout persists the workflow token in
`.git/config` by default, so a dependency lifecycle script could read it. Set
`persist-credentials: false`: the steps that need the API already pass
`secrets.GITHUB_TOKEN` explicitly.

Docs: docs/autonomous-dev.md
Docs-not-needed: no

@HugoXK-bot HugoXK-bot left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: PASS at 28ac4cd

The job has exactly one checkout (.github/workflows/release.yml:53) and it now sets persist-credentials: false (:57), so .git/config holds no token while npm ci (:63) runs dependency scripts; every step that needs the API passes its own credential — GH_TOKEN (:85, :209), GHCR_TOKEN (:156), registry-password (:178) — and the only job-level env is RELEASE_TAG.
No step lost a credential it needs: git fetch origin main (:88) is an anonymous HTTPS fetch on this public repository, and docker login (:156-157) happens after the install, so nothing in the install path reads a credential store.
Non-blocking: test/releasePublishToken.test.ts:97-101 matches raw text, so a commented-out # persist-credentials: false still passes (measured below); strip # comments from the step lines before matching.
Non-blocking, now resolved: the pr-lint red on the earlier body was only its ## Ran: / ## Not run: headings; the body has been fixed and pr-lint is green (run 133147560035).

Findings: none blocking; the two points above are the only ones.

Ran:

  • npm run check at this head in a clean tree: exit 0, 2405 tests / 2405 pass, lint + tsc + build clean.
  • npx tsx --test test/releasePublishToken.test.ts at this head: 1 pass / 0 fail; with the base release.yml swapped in: 1 fail / 0 pass.
  • Mutation at this head, delete persist-credentials: false: 1 fail / 0 pass.
  • Mutation at this head, add a second checkout in the same job with no flag: 1 fail / 0 pass.
  • Mutation at this head, comment the flag out: still 1 pass / 0 fail — the blind spot recorded above.
  • node scripts/changelog.mjs check at this head: 23 fragment(s) ok.
  • GITHUB_REPOSITORY=HugoXK/fledge node scripts/pr-lint.mjs --pr 904 on the base tree: FAIL, the two body-heading errors only.

Not run:

  • A real tag publish: it pushes an image and a release, and that is the owner's action.
  • No live release.yml run; the diff is a with: key plus a text-level test.

Written-by: HugoXK-bot
Author: Fledge Platform Verdict

@HugoXK
HugoXK merged commit 482488a into main Nov 16, 2026
34 of 37 checks passed
@HugoXK
HugoXK deleted the dev2/861-release-npm-token branch November 16, 2026 07:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ci: release publish runs npm ci with a persisted write token and id-token

2 participants