Skip to content

Fix CI deployment for forks and dynamic URLs#6827

Merged
ckifer merged 1 commit into
mainfrom
fix/ci-fork-deployment
Dec 26, 2025
Merged

Fix CI deployment for forks and dynamic URLs#6827
ckifer merged 1 commit into
mainfrom
fix/ci-fork-deployment

Conversation

@PavelVanecek

@PavelVanecek PavelVanecek commented Dec 26, 2025

Copy link
Copy Markdown
Collaborator

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

  • 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

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Dec 26, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

The 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

Cohort / File(s) Summary
CI Workflow Updates
.github/workflows/ci.yml
Deploy step gains id and stricter conditional; PR comment step now depends on steps.deploy.outcome == 'success'; URL generation for website and test reports switched from hardcoded paths to dynamic construction using REPO_OWNER and REPO_NAME context variables.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description is minimal and incomplete, lacking required template sections such as Related Issue, Motivation and Context, How Has This Been Tested, and Types of changes checklist. Complete the PR description template by adding sections for Related Issue, Motivation and Context, detailed testing explanation, and marking the appropriate change type checkbox.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main changes: fixing CI deployment for forks and implementing dynamic URLs, which matches the core modifications to the GitHub Actions workflow.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/ci-fork-deployment

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d52345f and 3e359cf.

📒 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.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_URL calculation 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

📥 Commits

Reviewing files that changed from the base of the PR and between d52345f and 3e359cf.

📒 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

codecov Bot commented Dec 26, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.56%. Comparing base (d52345f) to head (3e359cf).
⚠️ Report is 3 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

Copy link
Copy Markdown
Contributor

Staging Deployment Details

These deployments will remain available for 30 days.

To update snapshots: Comment /update-snapshots on this PR to automatically update the baseline screenshots.

@codecov

codecov Bot commented Dec 26, 2025

Copy link
Copy Markdown

Bundle Report

Bundle size has no change ✅

@ckifer
ckifer merged commit b48c80a into main Dec 26, 2025
44 checks passed
@ckifer
ckifer deleted the fix/ci-fork-deployment branch December 26, 2025 18:36
cloud-walker pushed a commit to cloud-walker/recharts that referenced this pull request Dec 28, 2025
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 -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants