Skip to content

Commit 2e7e819

Browse files
committed
Use rossjrw/pr-preview-action for PR previews
This action handles all the complexity of deploying PR previews to GitHub Pages, including creating the gh-pages branch if needed, organizing previews by PR number, and automatically cleaning up when PRs are closed.
1 parent 5405f71 commit 2e7e819

File tree

3 files changed

+60
-140
lines changed

3 files changed

+60
-140
lines changed

.github/workflows/pr-cleanup.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Deploy PR Preview
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- reopened
8+
- synchronize
9+
- closed
10+
11+
concurrency: preview-${{ github.ref }}
12+
13+
jobs:
14+
build-and-preview:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
pull-requests: write # Allow commenting on PRs
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
# Install uv for faster dependency management
22+
- name: Install uv
23+
if: github.event.action != 'closed'
24+
uses: astral-sh/setup-uv@v4
25+
with:
26+
enable-cache: true
27+
28+
# Set up Python using uv
29+
- name: Set up Python
30+
if: github.event.action != 'closed'
31+
run: uv python install 3.11
32+
33+
# Install dependencies using uv
34+
- name: Install dependencies
35+
if: github.event.action != 'closed'
36+
run: uv sync
37+
38+
# Cache executed notebooks between runs
39+
- name: Cache executed notebooks
40+
if: github.event.action != 'closed'
41+
uses: actions/cache@v4
42+
with:
43+
path: _build/.jupyter_cache
44+
key: jupyter-book-cache-${{ hashFiles('uv.lock') }}
45+
46+
# Build the book
47+
- name: Build the book
48+
if: github.event.action != 'closed'
49+
run: |
50+
uv run jupyter-book build .
51+
52+
# Deploy PR Preview using rossjrw/pr-preview-action
53+
- name: Deploy PR Preview
54+
uses: rossjrw/pr-preview-action@v1
55+
with:
56+
source-dir: _build/html/
57+
preview-branch: gh-pages
58+
umbrella-dir: pr-preview
59+
action: auto
60+
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/pr-preview-gh-pages.yml

Lines changed: 0 additions & 106 deletions
This file was deleted.

0 commit comments

Comments
 (0)