Skip to content
Merged
Show file tree
Hide file tree
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
50 changes: 16 additions & 34 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -1,55 +1,37 @@
name: Deploy to GitHub Pages

on:
# Deploy main branch to production
push:
branches: ["main"]

# Deploy PR previews
pull_request:
branches: ["main"]
types: [opened, synchronize, reopened, closed]

# Allow manual deployment
workflow_dispatch:

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

concurrency:
group: pages-${{ github.ref }}
group: "pages"
cancel-in-progress: false

jobs:
deploy:
# Skip on PR close events (handled by cleanup job)
if: github.event.action != 'closed'
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Deploy to GitHub Pages
uses: rossjrw/pr-preview-action@v1
with:
source-dir: ./docs
preview-branch: gh-pages
umbrella-dir: pr-previews
action: auto

cleanup:
# Only run when PR is closed
if: github.event.action == 'closed'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v4

- name: Remove PR Preview
uses: rossjrw/pr-preview-action@v1
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
source-dir: ./docs
preview-branch: gh-pages
umbrella-dir: pr-previews
action: remove
path: './docs'

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
46 changes: 46 additions & 0 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: PR Preview Build

on:
pull_request:
branches: ["main"]

permissions:
contents: read
pull-requests: write

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Upload docs artifact
uses: actions/upload-artifact@v4
with:
name: pr-preview-${{ github.event.pull_request.number }}
path: './docs'
retention-days: 7

- name: Comment PR
uses: actions/github-script@v7
with:
script: |
const prNumber = context.issue.number;
const runId = context.runId;
const comment = `## 📦 PR Preview Built

The site has been built and is available as a downloadable artifact in this workflow run.

**To preview locally:**
1. Download the artifact from the [workflow run](https://github.com/${{ github.repository }}/actions/runs/${runId})
2. Extract and open \`index.html\` in your browser

Or wait for this PR to be merged to see it live on GitHub Pages.`;

github.rest.issues.createComment({
issue_number: prNumber,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});
Loading