Repository navigation
🔒 ci: publish to npm via Trusted Publishing (OIDC) instead of NPM_TOKEN - #303
Conversation
Signed-off-by: Andrew Anderson <andy@clubanderson.com>
f1a39a7
ℹ️ Sentinel notice — informational; author is trusted (owner), merge is not blockedHive flagged this PR (author @clubanderson, head
Hive did not add the |
|
/hold cancel Trusted publisher registered on npmjs.com for @hivecommons/pluk (hivecommons/pluk, publish.yml, env |
|
@clubanderson: you cannot LGTM your own PR. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: clubanderson The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
There was a problem hiding this comment.
Reviewed (correctness) — workflow change is sound; one advisory on the environment settings.
.github/workflows/publish.yml:50-53,56-60,92-93:environment: npm+ job-levelid-token: write,setup-nodewithregistry-urland noNODE_AUTH_TOKEN, thennpm publish --provenance— identical shape to hivecommons/rationguardpublish.ymllines 62-95, whose tag runs (v0.11.0–v0.13.0) all succeeded, so the${NODE_AUTH_TOKEN}placeholder.npmrcthatsetup-nodewrites does not break OIDC on npm ≥ 11.5.1. Theverify-tag→publish→releasechain is unchanged.- Advisory (settings, not code):
GET /repos/hivecommons/pluk/environments/npmshows only abranch_policy(v*tag) — norequired_reviewers. Issue #293 checkbox 3 asks for "tag restrictionv*and required reviewer" so thatauto-release.yml's dispatch becomes an approve-to-publish step. Either add a reviewer on thenpmenvironment before closing #293, or note in the PR body that the reviewer gate was deliberately omitted so the checkbox can be ticked accurately.
— hive: agent=adjudicator backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Reviewed (security) — no in-scope findings. Verified at head f1a39a7: publish job has job-level contents: read + id-token: write and environment: npm (.github/workflows/publish.yml:50-53); the npm environment exists with a v* tag deployment policy; npm publish runs with no NODE_AUTH_TOKEN/secrets.* (publish.yml:92-93); the npm upgrade is version-pinned (publish.yml:68).
Out-of-scope advisory (pre-existing, backlog): workflow-level permissions still grants id-token: write to every job (publish.yml:9-11), so verify-tag receives an OIDC-capable token it never uses. Now that publish declares its own permissions, the top-level block can be narrowed:
permissions:
contents: read
— hive: agent=ci-maintainer backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Hive filed review findings that do not block this PR as backlog items:
Cap: 10 backlog item(s) per PR per day. |
There was a problem hiding this comment.
Reviewed (style/maintainability) — one advisory, non-blocking. Read at f1a39a7.
id-token: write is now declared twice — .github/workflows/publish.yml:9-11 (workflow level, pre-existing) and :51-53 (job level, added by this PR). The job-level block is the right place for it, but leaving the workflow-level grant means two places to keep in sync, and verify-tag (:14) still gets an OIDC token it never uses. Suggest narrowing the top-level block so the job-level declaration is the single source of truth:
permissions:
contents: read
(release already declares its own contents: write at :100-101, so nothing else depends on the top-level block.)
Everything else — the version guard (:61-70), preflight (:86-91), unnamed npm publish → named step (:92-93), and the runbook wording (runbooks/publish-failure.md:32-36) — matches the block prescribed in #293 and the rationguard counterpart.
— hive: agent=adjudicator backend=copilot model=claude-fable-5.1 copilot=1.0.88
Closes #293
Switch the
publishjob in.github/workflows/publish.ymlfrom a long-livedNPM_TOKENrepository secret to npm Trusted Publishing (GitHub Actions OIDC), mirroring hivecommons/rationguard#252 and hivecommons/promptargs#223.Workflow changes
publishjob now runs in thenpmGitHub Environment (created; deployment restricted tov*tags) with job-levelpermissions: { contents: read, id-token: write }.npm install -g npm@11.5.1only if the bundled npm is older — nevernpm@latestinside the job holding the OIDC token).ACTIONS_ID_TOKEN_REQUEST_URLis unset.npm publish --access public --provenancewith noNODE_AUTH_TOKEN/NPM_TOKEN(npm rejects OIDC publishes when a token is also present).runbooks/publish-failure.mdupdated to describe OIDC auth instead ofNPM_TOKEN.npm-side prerequisite (⚠️ must be done before merging — PR is on
hold)On npmjs.com →
@hivecommons/pluk→ Settings → Trusted Publisher → GitHub Actions: organizationhivecommons, repositorypluk, workflow filenamepublish.yml, environmentnpm. Equivalent CLI:npm trust github @hivecommons/pluk --repo hivecommons/pluk --file publish.yml --env npm --allow-publish.After this PR merges and the first OIDC publish succeeds: set Publishing access to "Require 2FA and disallow tokens", revoke the npm token, and delete the
NPM_TOKENrepository secret.