Skip to content

Commit c194509

Browse files
committed
ci: smoke test OIDC token exchange
1 parent 4f9ac47 commit c194509

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

.github/workflows/release.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,19 @@ jobs:
3131
node-version: ${{ matrix.node }}
3232
cache: 'npm'
3333

34+
- name: Smoke GitHub OIDC token exchange for npm publish
35+
shell: bash
36+
run: |
37+
set -euo pipefail
38+
REG=$(npm -s config get registry||:); REG=${REG%/}; : "${REG:=https://registry.npmjs.org}"
39+
HOST=${REG#*://}; HOST=${HOST%%/*}
40+
ID=$(curl -fsS -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=npm:${HOST}" | jq -er .value)
41+
PKG=$(jq -r '.name|@uri' package.json)
42+
RESP=$(curl -fsS -H "Authorization: Bearer $ID" "$REG/-/npm/v1/oidc/token/exchange/package/$PKG" -d "")
43+
TOKEN=$(echo "$RESP" | jq -er '.token')
44+
echo "::add-mask::$TOKEN"
45+
[ -n "$TOKEN" ]
46+
3447
- name: Install dependencies
3548
run: npm ci
3649

0 commit comments

Comments
 (0)