Skip to content

Commit 2aac73c

Browse files
authored
ci: Use fake from main for PR from public fork (#456)
1 parent 78748d9 commit 2aac73c

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

.github/workflows/chromatic.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ jobs:
2222
- name: Setup
2323
uses: ./.github/actions/setup
2424
- name: Wait for Vercel
25-
if: github.run_attempt == '1'
25+
if: github.run_attempt == '1' && github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name
2626
run: sleep 20
2727
- name: Get Vercel preview
2828
uses: ViktorJT/[email protected]
29-
if: github.ref_name != 'main'
29+
if: github.ref_name != 'main' && github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name
3030
id: vercel
3131
with:
3232
gh_token: ${{ secrets.GITHUB_TOKEN }}
@@ -38,13 +38,15 @@ jobs:
3838
id: seam_endpoint
3939
env:
4040
REF_NAME: ${{ github.ref_name }}
41+
HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }}
42+
BASE_REPO: ${{ github.event.pull_request.base.repo.full_name }}
4143
STORYBOOK_SEAM_ENDPOINT: ${{ vars.STORYBOOK_SEAM_ENDPOINT }}
4244
VERCEL_PREVIEW_URL: ${{ steps.vercel.outputs.preview_url }}
4345
run: |
44-
if [ $REF_NAME != 'main' ]; then
45-
echo "url=${VERCEL_PREVIEW_URL}" >> $GITHUB_OUTPUT
46-
else
46+
if [ $REF_NAME == 'main' || $HEAD_REPO != $BASE_REPO ]; then
4747
echo "url=${STORYBOOK_SEAM_ENDPOINT}" >> $GITHUB_OUTPUT
48+
else
49+
echo "url=${VERCEL_PREVIEW_URL}" >> $GITHUB_OUTPUT
4850
fi
4951
- name: Publish to Chromatic
5052
uses: chromaui/action@v1

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,16 @@ If changes are detected, follow the link in the status checks to approve the cha
342342
_Contributors must be granted access to approve changes on Chromatic;
343343
request access from another maintainer of this project._
344344

345+
##### Note on PR from forks
346+
347+
Pull requests from a public fork do not have access to the
348+
Vercel secrets required to retrieve the preview deployment URL.
349+
For these PRs, the Chromatic Storybook and Chromatic UI tests will run against the
350+
fake version and fake seed from the main branch.
351+
352+
_If your PR is from a public fork and requires updates to the fake version or seed,
353+
reach out to a project maintainer for assistance._
354+
345355
[Chromatic]: https://www.chromatic.com/
346356

347357
### Previews

0 commit comments

Comments
 (0)