ci: verify npm publish credentials on PRs (preflight) - #52
Merged
Conversation
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.
ratchapol-an
approved these changes
Aug 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a
npm-publish-preflightjob to PR CI (.github/workflows/checks.yml) that verifies thenpm_tokensecret can actually publish before we merge to master — instead of only finding out via anE403during the changeset publish on master.Why
The master publish has been failing with:
All four packages (
agoda-devfeedback-common,-vite2,-webpack,-rsbuild) are currently owned solely by the npm usermvedernikov. 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 hasread-writeon each already-published package.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.