Skip to content

ci: let maintainers run Chromatic for fork PRs via a label - #3273

Merged
interactivellama merged 1 commit into
masterfrom
ci/chromatic-external-label
Oct 30, 2026
Merged

interactivellama merged 1 commit into
masterfrom
ci/chromatic-external-label

Conversation

@interactivellama

@interactivellama interactivellama commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Chromatic only runs on: push, so PRs from forks get no visual review (no secrets, no push event in this repo). This adds two workflows, chromatic-external.yml (label added) and chromatic-external-remove-label.yml (PR synchronize):

  • Run: a user who can edit labels (triage access or higher) adds the run-chromatic label to a fork PR. The job checks out the PR head SHA from the fork and publishes to Chromatic.
  • Revoke: on every synchronize (new push to the PR), the label is removed, so new commits must be re-reviewed and re-labeled.

Security notes

pull_request_target exposes CHROMATIC_PROJECT_TOKEN while building fork code, so the guards matter:

  • Trigger is the label itself: GitHub only lets users with triage access or higher add labels, so there is no separate permission check. Do not let bots or other automation apply run-chromatic.
  • Checkout is pinned to the head SHA at label time, so a push racing the label cannot swap in unreviewed code.
  • Fork PRs only (same-repo branches are covered by the existing push workflow); permissions: {} at top level, contents: read for the run job, pull-requests: write only for label removal; persist-credentials: false.
  • A per-PR concurrency group (set at job level, so unrelated labels do not cancel a run) shared by both workflows cancels an in-flight run when a new push or the label arrives.
  • Reviewers should still review the diff (including package.json/scripts) before labeling, since npm ci and the Storybook build execute PR code.

Before merge / after merge

  • Create the run-chromatic label in the repo.
  • Confirm CHROMATIC_PROJECT_TOKEN is available to pull_request_target runs.
  • Note: pull_request_target workflows run from the default branch, so this can only be exercised on a fork PR after merging.

Also documents the flow in CONTRIBUTING.md.

@interactivellama
interactivellama force-pushed the ci/chromatic-external-label branch 3 times, most recently from c1c931d to 115a7bd Compare October 30, 2026 22:11
Fork PRs get no Chromatic run from the push workflow. Add a
pull_request_target workflow that runs Chromatic when a user who can
edit labels (triage access or higher) adds the run-chromatic label,
pinned to the labeled head SHA, and removes the label on every PR
synchronize so new commits need re-approval.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@interactivellama
interactivellama force-pushed the ci/chromatic-external-label branch from 115a7bd to fe5b010 Compare October 30, 2026 22:17
@interactivellama interactivellama changed the title ci: let admins run Chromatic for fork PRs via a label ci: let maintainers run Chromatic for fork PRs via a label Oct 30, 2026
@interactivellama
interactivellama merged commit 0bd951f into master Oct 30, 2026
10 checks passed
@interactivellama
interactivellama deleted the ci/chromatic-external-label branch October 30, 2026 23:09
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.

1 participant