Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(ci): skip preview/comment jobs on fork PRs (#3129)

Cindy Zhang699d4c1f0b92
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index a4646bb287..65a95cb3a1 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -277,8 +277,14 @@ jobs:
# Uses a per-PR concurrency group so multiple PRs deploy in parallel.
# Instead of peaceiris/actions-gh-pages (which can conflict with main's
# force-push), we do a manual git push with retry-on-conflict.
+ # Fork PRs run with a read-only GITHUB_TOKEN, so the `git push origin gh-pages`
+ # below would 403. Skip on forks (neutral, not failing). A maintainer can deploy
+ # a trusted fork PR's preview manually via the Re-deploy Preview workflow.
deploy-preview:
- if: github.event_name == 'pull_request' && needs.check-scope.outputs.docsite_only != 'true'
+ if: >-
+ github.event_name == 'pull_request' &&
+ needs.check-scope.outputs.docsite_only != 'true' &&
+ github.event.pull_request.head.repo.full_name == github.repository
needs: [build, check-scope]
runs-on: ubuntu-latest
permissions:
@@ -344,8 +350,14 @@ jobs:
# Post PR comment with preview links + analysis as soon as build finishes
# Does NOT wait for test or a11y — those update the comment later
+ # Posting a comment needs `pull-requests: write`, which fork PRs don't get
+ # (their GITHUB_TOKEN is read-only). Skip on forks so the check stays neutral
+ # instead of failing. The analysis artifact is still uploaded by `build`.
pr-comment:
- if: github.event_name == 'pull_request' && needs.check-scope.outputs.docsite_only != 'true'
+ if: >-
+ github.event_name == 'pull_request' &&
+ needs.check-scope.outputs.docsite_only != 'true' &&
+ github.event.pull_request.head.repo.full_name == github.repository
needs: [build, check-scope]
runs-on: ubuntu-latest
permissions:
@@ -467,10 +479,15 @@ jobs:
path: a11y-report.json
retention-days: 1
- # Update PR comment with a11y results once they're ready
+ # Update PR comment with a11y results once they're ready.
+ # Skipped on fork PRs for the same read-only-token reason as pr-comment.
pr-comment-update:
needs: [build, check-components, pr-a11y]
- if: always() && github.event_name == 'pull_request' && needs.build.result == 'success' && needs.check-components.outputs.has_components == 'true'
+ if: >-
+ always() && github.event_name == 'pull_request' &&
+ needs.build.result == 'success' &&
+ needs.check-components.outputs.has_components == 'true' &&
+ github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
permissions:
contents: read
diff --git a/.github/workflows/vercel-preview.yml b/.github/workflows/vercel-preview.yml
index f9078f2a70..26dbbe51c5 100644
--- a/.github/workflows/vercel-preview.yml
+++ b/.github/workflows/vercel-preview.yml
@@ -26,6 +26,12 @@ concurrency:
jobs:
deploy-preview:
+ # Fork PRs don't receive repository secrets, so VERCEL_TOKEN/ORG/PROJECT are
+ # empty and `vercel pull` fails. Their GITHUB_TOKEN is also read-only, so the
+ # PR comment can't post either. Skip on forks (neutral, not failing); the
+ # Vercel GitHub App still posts its own "authorize this preview" comment, and
+ # a maintainer can authorize the deploy from the Vercel dashboard.
+ if: github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
permissions:
contents: read