Skip to content

Commit 4486aa6

Browse files
authored
Deployment previews for forks (#2207)
* Create deploy_preview_forks.yml * skip original deployment on forks * add comment to explain the conditional
1 parent 428930d commit 4486aa6

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

.github/workflows/deploy_preview.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ permissions:
99

1010
jobs:
1111
deploy-preview:
12-
if: ${{ github.repository == 'primer/react' }}
12+
# if the source repository for pull request is a fork, we don't want to run this workflow,
13+
# we run deploy_preview_forks.yml which uses pull_request_target instead.
14+
# see https://github.com/primer/react/pull/2207 for details
15+
if: ${{ github.event.pull_request.head.repo.full_name == 'primer/react' }} # source repository for pull_request
1316
name: Preview
1417
uses: primer/.github/.github/workflows/deploy_preview.yml@main
1518
permissions:
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Deploy (fork)
2+
on:
3+
pull_request_target:
4+
5+
permissions:
6+
contents: read
7+
pages: write
8+
id-token: write
9+
10+
jobs:
11+
deploy-preview:
12+
if: ${{ github.repository == 'primer/react' }} # target repository for pull_request
13+
name: Preview
14+
uses: primer/.github/.github/workflows/deploy_preview.yml@main
15+
permissions:
16+
contents: read
17+
pages: write
18+
id-token: write
19+
with:
20+
node_version: 14
21+
install: npm ci && cd docs && npm ci && cd ..
22+
build: npm run build:docs:preview
23+
output_dir: docs/public

0 commit comments

Comments
 (0)