Skip to content

Commit 4f11de3

Browse files
committed
ci(astro): one-shot OIDC claim dump for Trusted Publisher debug
Diagnostic step that decodes the GitHub OIDC token's JWT payload (no signed-token leak — just the claims). Lets us compare what npm sees against the Trusted Publisher config on npmjs.com when publish 404s during initial setup. Removed once OIDC publish is confirmed working.
1 parent 2c8803d commit 4f11de3

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

.github/workflows/publish-astro.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,29 @@ jobs:
100100
- name: Build
101101
run: npm run build --workspace=astro
102102

103+
# One-shot diagnostic: dump the OIDC token's claims (just the JWT
104+
# payload, NOT the signed token itself, so it's safe to log) so we
105+
# can compare claims-as-seen-by-npm against the Trusted Publisher
106+
# config on npmjs.com. Remove this step once OIDC publish is
107+
# confirmed working.
108+
- name: Debug OIDC claims
109+
run: |
110+
set -euo pipefail
111+
# Request a token scoped to npm registry's expected audience.
112+
# The token request URL + bearer come from GH-injected env vars
113+
# only available because permissions.id-token: write is set.
114+
RESP=$(curl -sSL -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
115+
"${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=npm:registry.npmjs.org")
116+
TOKEN=$(echo "$RESP" | node -e 'let s=""; process.stdin.on("data",d=>s+=d).on("end",()=>{console.log(JSON.parse(s).value)})')
117+
# Decode the JWT payload (middle segment). DO NOT echo $TOKEN.
118+
PAYLOAD=$(echo "$TOKEN" | cut -d. -f2)
119+
# Pad base64url to a multiple of 4 so `base64 -d` accepts it.
120+
PAD=$((4 - ${#PAYLOAD} % 4))
121+
if [ $PAD -ne 4 ]; then PAYLOAD="${PAYLOAD}$(printf '%*s' $PAD | tr ' ' '=')"; fi
122+
# base64url → base64 (replace - / _)
123+
PAYLOAD=$(echo "$PAYLOAD" | tr '_-' '/+')
124+
echo "$PAYLOAD" | base64 -d | node -e 'let s=""; process.stdin.on("data",d=>s+=d).on("end",()=>{const c=JSON.parse(s); const keep=["aud","iss","sub","repository","repository_owner","repository_id","workflow","workflow_ref","job_workflow_ref","ref","event_name","environment","actor"]; for (const k of keep) if (k in c) console.log(k+": "+JSON.stringify(c[k]));})'
125+
103126
- name: Bump version
104127
id: bump
105128
run: |

0 commit comments

Comments
 (0)