Skip to content

Commit 63d9c8b

Browse files
authored
Merge pull request #24 from proxymesh/ci/publish-oidc-unset-token
ci: fix npm OIDC publish (unset NODE_AUTH_TOKEN)
2 parents cdc4860 + e1c7012 commit 63d9c8b

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

.github/workflows/publish.yml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ on:
1111
workflows: [Release on merge]
1212
types: [completed]
1313

14-
permissions:
15-
contents: read
16-
id-token: write
17-
1814
jobs:
1915
publish:
2016
if: >-
2117
github.event_name != 'workflow_run' ||
2218
github.event.workflow_run.conclusion == 'success'
2319
runs-on: ubuntu-latest
20+
# Explicit job permissions: org default token scopes must not block OIDC.
21+
permissions:
22+
contents: read
23+
id-token: write
2424
steps:
2525
- uses: actions/checkout@v6
2626
with:
@@ -87,9 +87,18 @@ jobs:
8787
if: steps.gate.outputs.publish == 'true'
8888
run: npm install --ignore-scripts --no-package-lock
8989

90+
# If NODE_AUTH_TOKEN / NPM_TOKEN are set to empty or a placeholder (repo/org Variables,
91+
# or setup-node + registry-url), npm prefers them over OIDC and fails with ENEEDAUTH.
9092
- name: Publish to npm
9193
if: steps.gate.outputs.publish == 'true'
92-
run: npm publish --access public --provenance
94+
run: |
95+
set -euo pipefail
96+
if [[ -z "${ACTIONS_ID_TOKEN_REQUEST_URL:-}" || -z "${ACTIONS_ID_TOKEN_REQUEST_TOKEN:-}" ]]; then
97+
echo "::error::GitHub OIDC is unavailable (missing ACTIONS_ID_TOKEN_*). Check job permissions id-token: write and repo Settings → Actions → Workflow permissions."
98+
exit 1
99+
fi
100+
unset NODE_AUTH_TOKEN NPM_TOKEN
101+
npm publish --access public --provenance
93102
94103
- name: Publish to JSR
95104
if: steps.gate.outputs.publish == 'true'

0 commit comments

Comments
 (0)