Skip to content

Commit fdb7100

Browse files
docs(README): update auth token mechanism (#920)
* docs(README): update nodejs to conform new npm release process * docs(README): revert releaserc yml changes * docs(README): update yml files to fix release * docs(README): add verbose to releaserc yml * docs(README): remove tokens in nodejs yml * docs(README): revert whoami changes * docs(README): update auth token mechanism
1 parent 68c11a8 commit fdb7100

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

.github/workflows/nodejs.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,24 @@ jobs:
6868

6969
- run: yarn install --frozen-lockfile
7070
- run: yarn build
71+
72+
- name: Exchange OIDC token for npm token
73+
id: npm-oidc
74+
run: |
75+
# Get GitHub OIDC token
76+
OIDC_TOKEN=$(curl -sS -H "Authorization: Bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
77+
"${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=https://registry.npmjs.org" | jq -r '.value')
78+
79+
# Exchange for npm access token
80+
NPM_ACCESS_TOKEN=$(curl -sS -X POST "https://registry.npmjs.org/-/npm/v1/oidc/token" \
81+
-H "Content-Type: application/json" \
82+
-d "{\"oidcToken\": \"${OIDC_TOKEN}\"}" | jq -r '.token')
83+
84+
# Mask the token and export for subsequent steps
85+
echo "::add-mask::${NPM_ACCESS_TOKEN}"
86+
echo "NODE_AUTH_TOKEN=${NPM_ACCESS_TOKEN}" >> $GITHUB_ENV
87+
7188
- run: yarn run semantic-release
7289
env:
7390
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
74-
# NPM_TOKEN no longer needed - using OIDC trusted publishing
91+
# NODE_AUTH_TOKEN is set by the OIDC exchange step above

0 commit comments

Comments
 (0)