Skip to content

Commit 0223364

Browse files
cipolleschimeta-codesync[bot]
authored andcommitted
Validate NPM token before creating a release (#56501)
Summary: Pull Request resolved: #56501 Add an early NPM token validation step to the create-release workflow. This runs `npm whoami` right after checkout to fail fast if the token is expired or invalid, avoiding wasted CI time on a release that would fail at the publish step. The step gracefully skips when no token is present (e.g. fork PRs). ## Changelog: [Internal] - Reviewed By: christophpurrer Differential Revision: D101377190 fbshipit-source-id: 53243a24649f86d274b2ea31793333fd815e69cb
1 parent 6779f6c commit 0223364

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

.github/workflows/create-release.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,21 @@ jobs:
2828
token: ${{ secrets.REACT_NATIVE_BOT_GITHUB_TOKEN }}
2929
fetch-depth: 0
3030
fetch-tags: 'true'
31+
- name: Verify NPM token
32+
run: |
33+
if [[ -z "$GHA_NPM_TOKEN" ]]; then
34+
echo "⚠️ No NPM token found. Skipping validation."
35+
exit 0
36+
fi
37+
echo "//registry.npmjs.org/:_authToken=$GHA_NPM_TOKEN" > ~/.npmrc
38+
if ! npm whoami > /dev/null 2>&1; then
39+
echo "❌ NPM token is invalid or expired. Aborting release."
40+
exit 1
41+
fi
42+
echo "✅ NPM token is valid ($(npm whoami))"
43+
rm -f ~/.npmrc
44+
env:
45+
GHA_NPM_TOKEN: ${{ secrets.GHA_NPM_TOKEN }}
3146
- name: Check if on stable branch
3247
id: check_stable_branch
3348
run: |

0 commit comments

Comments
 (0)