Fix CI deployment for forks and dynamic URLs#6827
Conversation
WalkthroughThe CI workflow configuration gains enhanced deployment guards through stricter conditionals and dependencies. The deploy step now includes an ID and conditional check ensuring it runs only when not a pull request or when the pull request originates from the main repository. The PR comment step is made dependent on successful deployment. Additionally, URL generation for deployment reports becomes dynamic, deriving owner and repository names from workflow context. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used🧠 Learnings (2)📓 Common learnings📚 Learning: 2025-12-07T01:38:46.703ZApplied to files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
🔇 Additional comments (3)
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 |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
.github/workflows/ci.yml (1)
89-96: Make BASE_URL dynamic to match deployment URL logic.The
BASE_URLcalculation hardcodes/recharts/but should be dynamic to match the URL generation approach in lines 347-350. When this workflow runs in a fork (especially if renamed), the hardcoded path causes the built website to have incorrect asset paths and broken links.🔎 Proposed fix to make BASE_URL dynamic
- name: Calculate BASE_URL id: base_url run: | + REPO_NAME="${{ github.event.repository.name }}" if [ "${{ github.event_name }}" = "pull_request" ]; then - echo "BASE_URL=/recharts/pr-${{ github.event.pull_request.number }}/www/" >> $GITHUB_ENV + echo "BASE_URL=/$REPO_NAME/pr-${{ github.event.pull_request.number }}/www/" >> $GITHUB_ENV else - echo "BASE_URL=/recharts/canary/www/" >> $GITHUB_ENV + echo "BASE_URL=/$REPO_NAME/canary/www/" >> $GITHUB_ENV fi
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/ci.yml
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6748
File: .github/workflows/ci.yml:268-276
Timestamp: 2025-12-07T01:38:46.703Z
Learning: In the recharts/recharts repository, the staging deployment pipeline should deploy the website and VR test report even when VR tests fail, so that the HTML report can be reviewed. This requires using `if: always() && needs.build_test_pack.result == 'success' && (needs.vr_tests.result == 'success' || needs.vr_tests.result == 'failure')` in the deploy_staging job condition.
📚 Learning: 2025-12-07T01:38:46.703Z
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6748
File: .github/workflows/ci.yml:268-276
Timestamp: 2025-12-07T01:38:46.703Z
Learning: In the recharts/recharts repository, the staging deployment pipeline should deploy the website and VR test report even when VR tests fail, so that the HTML report can be reviewed. This requires using `if: always() && needs.build_test_pack.result == 'success' && (needs.vr_tests.result == 'success' || needs.vr_tests.result == 'failure')` in the deploy_staging job condition.
Applied to files:
.github/workflows/ci.yml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Build, Test, Pack
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (3)
.github/workflows/ci.yml (3)
316-317: LGTM! Security improvement for fork deployments.The conditional correctly prevents PRs from forks from deploying to the main repository's gh-pages branch while still allowing same-repository PRs and push events to deploy. The step ID enables downstream checks.
342-342: LGTM! Proper guard for comment posting.The additional check ensures the PR comment is only posted when deployment actually succeeds, preventing misleading comments with inaccessible URLs when the deploy step is skipped for fork PRs.
347-350: LGTM! Dynamic URLs enable fork deployments.The dynamic URL generation correctly constructs deployment URLs based on the repository context, enabling forks to deploy to their own GitHub Pages while maintaining correct URLs for the main repository.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6827 +/- ##
=======================================
Coverage 93.56% 93.56%
=======================================
Files 523 523
Lines 46462 46462
Branches 5055 5055
=======================================
Hits 43472 43472
Misses 2983 2983
Partials 7 7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Staging Deployment Details
These deployments will remain available for 30 days. To update snapshots: Comment |
Bundle ReportBundle size has no change ✅ |
We can't allow deploying to our main website from forks but we can allow deploying from the fork so let's do that. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Enhanced CI/CD pipeline deployment controls to improve security and reliability * Improved preview site and test report URL generation for better repository configuration support * Strengthened validation for pull request status checks and comments <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
We can't allow deploying to our main website from forks but we can allow deploying from the fork so let's do that.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.