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
21 changes: 15 additions & 6 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
name: Deploy PR previews

on:
workflow_dispatch:
inputs:
pr_number:
description: pull request number
required: true
type: number
pull_request:
types: [opened, synchronize, reopened, closed]
types: [closed]

permissions:
contents: write
pull-requests: write

concurrency:
group: pr-${{ github.event.pull_request.number }}
group: pr-${{ github.event.pull_request.number || github.event.inputs.pr_number }}
cancel-in-progress: true

env:
PAGE_DIR: pr-preview-${{ github.event.pull_request.number }}
BASE_PATH: /preview/pr-preview-${{ github.event.pull_request.number }}
PR_NUMBER: ${{ github.event.pull_request.number || github.event.inputs.pr_number }}
PAGE_DIR: pr-preview-${{ github.event.pull_request.number || github.event.inputs.pr_number }}
BASE_PATH: /preview/pr-preview-${{ github.event.pull_request.number || github.event.inputs.pr_number }}

jobs:
build-and-commit:
Expand All @@ -23,6 +30,8 @@ jobs:
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
ref: refs/pull/${{ env.PR_NUMBER }}/head

- name: Build Check
uses: ./.github/actions/build
Expand All @@ -45,7 +54,7 @@ jobs:
cp -r -f /tmp/out/* ./preview/${{env.PAGE_DIR}}
touch ./preview/${{env.PAGE_DIR}}/.nojekyll || true
git add .
git commit -m "Deploy PR preview for #${{ github.event.pull_request.number }}"
git commit -m "Deploy PR preview for #${{ env.PR_NUMBER }}"
git push origin gh-pages

- name: Comment PR
Expand Down Expand Up @@ -77,4 +86,4 @@ jobs:
git config user.name github-actions
git config user.email github-actions@github.com
git add .
git commit -m "Remove PR preview for #${{ github.event.pull_request.number }}" && git push origin gh-pages || echo "No changes to commit"
git commit -m "Remove PR preview for #${{ env.PR_NUMBER }}" && git push origin gh-pages || echo "No changes to commit"
Loading