ci: use Nx Cloud only on main, run PRs locally#53
Conversation
Fork PRs don't receive repository secrets, so NX_CLOUD_ACCESS_TOKEN is empty and the nx-cloud start-ci-run step fails for external contributors. Detect fork PRs and skip Nx Cloud distribution, running nx affected locally with NX_NO_CLOUD instead. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LKPMobWjRwcz9TDzS3Kryp
Disable Nx Cloud for all pull requests and only distribute/write the remote cache on pushes to main. This removes the dependency on the Nx Cloud access token for PRs (secrets are unavailable to fork PRs), so contributor PRs pass without any token exposure or fork special-casing. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LKPMobWjRwcz9TDzS3Kryp
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe CI workflow now runs Nx Cloud task distribution only for push events and disables Nx Cloud during pull request events through ChangesNx Cloud CI behavior
Estimated code review effort: 1 (Trivial) | ~5 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Problem
PRs from external contributors fail CI because GitHub does not expose repository secrets to workflows triggered by PRs from forks. As a result
NX_CLOUD_ACCESS_TOKENis empty on those runs, and thenx-cloud start-ci-rundistribution step fails when it tries to authenticate.Change
Stop depending on the Nx Cloud access token for pull requests. Nx Cloud (task distribution + remote cache writes) now runs only on pushes to
main; all pull requests — from this repo or a fork — runnx affectedlocally.start-ci-run)mainNX_NO_CLOUD)Concretely:
start-ci-runstep is gated ongithub.event_name == 'push'(onlymain, per the workflow triggers).nx affectedstep setsNX_NO_CLOUDforpull_requestevents, so PRs run tasks on the runner and never reference the token.Why this approach
main, so local dev machines andmainCI keep benefiting from it.pull_request_target, which would run untrusted fork code with a write-capableGITHUB_TOKENin scope.Trade-off: PR CI runs cold (no remote-cache reads). Negligible at this repo's size; can be revisited later by embedding a read-only token for cache reads if PR times grow.
🤖 Generated with Claude Code
https://claude.ai/code/session_01LKPMobWjRwcz9TDzS3Kryp
Generated by Claude Code
Summary by CodeRabbit