Skip to content

Commit

Permalink
Deployment previews for forks (#2207)
Browse files Browse the repository at this point in the history
* Create deploy_preview_forks.yml

* skip original deployment on forks

* add comment to explain the conditional
  • Loading branch information
siddharthkp authored Aug 4, 2022
1 parent 428930d commit 4486aa6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .github/workflows/deploy_preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ permissions:

jobs:
deploy-preview:
if: ${{ github.repository == 'primer/react' }}
# if the source repository for pull request is a fork, we don't want to run this workflow,
# we run deploy_preview_forks.yml which uses pull_request_target instead.
# see https://github.com/primer/react/pull/2207 for details
if: ${{ github.event.pull_request.head.repo.full_name == 'primer/react' }} # source repository for pull_request
name: Preview
uses: primer/.github/.github/workflows/deploy_preview.yml@main
permissions:
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/deploy_preview_forks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Deploy (fork)
on:
pull_request_target:

permissions:
contents: read
pages: write
id-token: write

jobs:
deploy-preview:
if: ${{ github.repository == 'primer/react' }} # target repository for pull_request
name: Preview
uses: primer/.github/.github/workflows/deploy_preview.yml@main
permissions:
contents: read
pages: write
id-token: write
with:
node_version: 14
install: npm ci && cd docs && npm ci && cd ..
build: npm run build:docs:preview
output_dir: docs/public

0 comments on commit 4486aa6

Please sign in to comment.