Skip to content

ci: verify npm publish credentials on PRs (preflight) - #52

Merged
joeldickson merged 2 commits into
masterfrom
ci/npm-publish-preflight
Aug 7, 2026
Merged

ci: verify npm publish credentials on PRs (preflight)#52
joeldickson merged 2 commits into
masterfrom
ci/npm-publish-preflight

Conversation

@joeldickson

Copy link
Copy Markdown
Contributor

What

Adds a npm-publish-preflight job to PR CI (.github/workflows/checks.yml) that verifies the npm_token secret can actually publish before we merge to master — instead of only finding out via an E403 during the changeset publish on master.

Why

The master publish has been failing with:

E403 403 Forbidden - PUT https://registry.npmjs.org/agoda-devfeedback-common
You do not have permission to publish "agoda-devfeedback-common".

All four packages (agoda-devfeedback-common, -vite2, -webpack, -rsbuild) are currently owned solely by the npm user mvedernikov. Renewing the token doesn't help if it belongs to a different account. This preflight makes that failure visible on the PR, so we have a fast loop to iterate on.

How it works

.github/scripts/npm-preflight.mjs:

  • npm whoami — fails fast if the token is invalid/expired, and prints the identity (answers npm's "Are you logged in as the correct user?").
  • npm access list packages --json — asserts the identity has read-write on each already-published package.
  • Packages not yet on npm pass with any valid token (first publish).
  • Fork PRs (no secret) skip cleanly.

Note

This surfaces the credential problem; it will only go green once the token belongs to an account with write access. The durable fix is to move these packages under an npm org + team (transfer keeps the same unscoped names) and use a dedicated bot account's automation token.

dicko2 added 2 commits August 6, 2026 11:32
Adds a pull_request job that verifies NPM_TOKEN can actually publish every
publishable workspace package before merge, so a wrong/expired/wrong-account
token fails the PR instead of only surfacing as an E403 during the master
changeset publish.

The script checks npm whoami (token validity + identity) and asserts the
identity has read-write access to each already-published package; unpublished
package names pass with any valid token (first publish). Fork PRs without the
secret skip cleanly.
npm access list packages only works for org accounts; for a personal
account it queries /-/org/<user>/package and 403s, which made the
preflight falsely report 'no access' for every package even when the
token identity was the correct sole owner.

Switch to a per-package 'npm access list collaborators <pkg> --json'
check, which works for both user- and org-owned packages. Not-yet-
published names still pass as first-publish.
@joeldickson
joeldickson requested a review from rayriffy August 7, 2026 05:44
@joeldickson
joeldickson merged commit bfde496 into master Aug 7, 2026
4 checks passed
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.

3 participants