-
Notifications
You must be signed in to change notification settings - Fork 17
chore: update GH actions to use trusted publisher #3161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR updates the publication workflow to use npm's OIDC trusted publisher authentication instead of token-based authentication. This change improves security by eliminating the need to store long-lived npm tokens as secrets and enables automated provenance generation for published packages.
Key changes:
- Added workflow-level permissions for
id-token,contents, andpackagesto enable OIDC authentication - Replaced the
NODE_AUTH_TOKENsecret with empty string values for bothNODE_AUTH_TOKENandNPM_TOKEN
| env: | ||
| NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }} | ||
| NODE_AUTH_TOKEN: '' | ||
| NPM_TOKEN: '' |
Copilot
AI
Dec 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using npm's trusted publisher (OIDC), empty strings should not be set for authentication tokens. These environment variables should either be omitted entirely or removed from the workflow. Setting them to empty strings serves no purpose and may cause confusion.
Remove these lines:
env:
NODE_AUTH_TOKEN: ''
NPM_TOKEN: ''| node-version: 22 | ||
| registry-url: https://registry.npmjs.org | ||
| - run: npm ci | ||
| - run: npm publish |
Copilot
AI
Dec 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using npm's trusted publisher with OIDC authentication, the npm publish command should include the --provenance flag to generate build provenance attestations. This is a key security benefit of trusted publishers.
Add the provenance flag:
- run: npm publish --provenanceThis ensures that the published package includes provenance information that verifies the package was built by this specific GitHub Actions workflow.
| - run: npm publish | |
| - run: npm publish --provenance |
| packages: write | ||
|
|
Copilot
AI
Dec 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The packages: write permission is not needed for publishing to npm. This permission is for GitHub Packages (ghcr.io), not npm registry. For npm publishing with trusted publisher, only id-token: write and contents: write (for release upload) are necessary.
Consider removing the unnecessary permission:
permissions:
contents: write
id-token: write| packages: write |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 file reviewed, 1 comment
| NODE_AUTH_TOKEN: '' | ||
| NPM_TOKEN: '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Setting NODE_AUTH_TOKEN and NPM_TOKEN to empty strings will break npm authentication. For OIDC-based trusted publishing, these environment variables should be removed entirely rather than set to empty strings. The setup-node action with id-token: write permission will handle OIDC token generation automatically, but only if NODE_AUTH_TOKEN isn't explicitly overridden.
Remove these lines and let setup-node handle authentication:
| NODE_AUTH_TOKEN: '' | |
| NPM_TOKEN: '' |
Prompt To Fix With AI
This is a comment left during a code review.
Path: .github/workflows/publication.yml
Line: 26:27
Comment:
**logic:** Setting `NODE_AUTH_TOKEN` and `NPM_TOKEN` to empty strings will break npm authentication. For OIDC-based trusted publishing, these environment variables should be **removed entirely** rather than set to empty strings. The `setup-node` action with `id-token: write` permission will handle OIDC token generation automatically, but only if `NODE_AUTH_TOKEN` isn't explicitly overridden.
Remove these lines and let `setup-node` handle authentication:
```suggestion
```
How can I resolve this? If you propose a fix, please make it concise.
Greptile Overview
Greptile Summary
This PR attempts to migrate the npm publication workflow from secrets-based authentication to OIDC-based "Trusted Publishing". The changes add the required permissions (
id-token: write,contents: write,packages: write) for OIDC token generation.permissionsblock with necessary OIDC and GitHub token permissionssecrets.NODE_AUTH_TOKENwith empty string valuesCritical Issue: Setting
NODE_AUTH_TOKEN: ''andNPM_TOKEN: ''to empty strings will likely break npm authentication. For OIDC trusted publishing to work, these environment variables should be removed entirely, allowingsetup-nodeaction to handle OIDC token generation automatically.Confidence Score: 1/5
Important Files Changed
File Analysis
Sequence Diagram
sequenceDiagram participant GH as GitHub Actions participant SN as setup-node Action participant NPM as npm Registry participant OIDC as GitHub OIDC Provider GH->>SN: Configure node with registry-url Note over GH: id-token: write permission granted GH->>NPM: npm publish Note over NPM: NODE_AUTH_TOKEN='' (empty) NPM-->>GH: ❌ Authentication Failed Note right of NPM: Empty token prevents<br/>both secret-based and<br/>OIDC authenticationCI Results
Test Status:⚠️ FLAKY
📊 Full Report
Test Changes Summary ⏭️2
⏭️ Skipped Tests (2)
Bundle Size: ✅
Current: 62.33 MB | Main: 62.33 MB
Diff: 0.00 KB (0.00%)
✅ Bundle size unchanged.
ℹ️ CI Information