Validate NPM token before nightly publish (#56502)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/56502

Adds an NPM token validation step to the `build_npm_package` job of the
React Native nightly workflow. Mirrors the same check we recently added
to `create-release.yml` and the Hermes `rn-build-hermes.yml` workflows
so we fail fast (with a clear message) instead of failing partway
through the publish step when the token is expired or missing.

## Changelog:
[Internal] -

Reviewed By: fabriziocucci

Differential Revision: D101594276

fbshipit-source-id: bb0fbddf5eba921f4184117dc29c7cc9e911a00e
This commit is contained in:
Riccardo Cipolleschi authored and meta-codesync[bot] committed 2026-04-20 03:19:02 -07:00
1 parent 0223364b43
commit 8043a6dfb7
1 file changed
+13
+13
View File
@@ -89,6 +89,19 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Verify NPM token
run: |
if [[ -z "$GHA_NPM_TOKEN" ]]; then
echo "⚠️ No NPM token found. Skipping validation."
exit 0
fi
echo "//registry.npmjs.org/:_authToken=$GHA_NPM_TOKEN" > ~/.npmrc
if ! npm whoami > /dev/null 2>&1; then
echo "❌ NPM token is invalid or expired. Aborting release."
exit 1
fi
echo "✅ NPM token is valid ($(npm whoami))"
rm -f ~/.npmrc
- name: Build and Publish NPM Package
uses: ./.github/actions/build-npm-package
with: