Skip to content

Commit 0ef321c

Browse files
committed
ci(release): never print the token-exchange response body
A successful exchange returns a publish token in the body, and this repository's Actions logs are public. The diagnostic now reports the status on success and prints the body only on failure, where the body is npm's error rather than a credential.
1 parent e3f8108 commit 0ef321c

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎.github/workflows/release.yml‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,13 @@ jobs:
143143
code="$(curl -sS -o exchange.json -w '%{http_code}' -X POST \
144144
-H "Authorization: bearer $token" -H 'Accept: application/json' --data '' \
145145
"https://registry.npmjs.org/-/npm/v1/oidc/token/exchange/package/$pkg")"
146-
echo "$pkg -> HTTP $code $(head -c 400 exchange.json)"
146+
if [ "$code" = "200" ]; then
147+
# A successful exchange returns a publish token in the body, and
148+
# this log is public. Report that it worked; never the token.
149+
echo "$pkg -> HTTP $code (exchange succeeded; body withheld)"
150+
else
151+
echo "$pkg -> HTTP $code $(head -c 400 exchange.json)"
152+
fi
147153
done
148154
149155
- name: Publish

0 commit comments

Comments
 (0)