Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions .github/workflows/deploy-preview.yaml
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
name: "Deploy Preview"

# Exactly one of the two triggers passes the deploy job's condition:
# - PRs from branches of this repository run via pull_request, so maintainers
# can modify and test this workflow. No label is required.
# - PRs from forks run via pull_request_target (which uses the workflow from the
# base branch) and only when labeled as safe.
on:
pull_request:
# allow repository maintainers to modify and test workflow
paths:
- ".github/workflows/deploy-preview.yaml"
pull_request_target: # zizmor: ignore[dangerous-triggers]
# enable runs for this workflow when labeled as safe only
# prevent execution when the workflow itself is modified from a fork
types:
- labeled
- synchronize

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

permissions: {}

jobs:
deploy-preview:
name: Build & Deploy
runs-on: ubuntu-latest
timeout-minutes: 15
if: |
(github.event_name == 'pull_request_target' && contains(github.event.pull_request.labels.*.name, 'safe'))
|| (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)
if: >
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)
|| (github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository
&& contains(github.event.pull_request.labels.*.name, 'safe'))
# Cancel stale runs so that an older run cannot deploy or update the comment
# after a newer one. This is defined on the job (not the workflow) so that
# runs whose job is skipped by the condition above do not cancel others.
concurrency:
group: deploy-preview-${{ github.event.pull_request.number }}
cancel-in-progress: true
environment:
name: Preview
url: ${{ steps.deploy.outputs.pages-deployment-alias-url || steps.deploy.outputs.deployment-url }}
Expand Down