Skip to content

Set up uv for dependency management and add PR preview workflow #4

Set up uv for dependency management and add PR preview workflow

Set up uv for dependency management and add PR preview workflow #4

Workflow file for this run

name: PR Preview
# Build the book on pull requests for preview
on:
pull_request:
branches:
- main
- master
jobs:
build-preview:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Install uv for faster dependency management
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
# Set up Python using uv
- name: Set up Python
run: uv python install 3.11
# Install dependencies using uv
- name: Install dependencies
run: uv sync
# Cache executed notebooks between runs
- name: Cache executed notebooks
uses: actions/cache@v4
with:
path: _build/.jupyter_cache
key: jupyter-book-cache-${{ hashFiles('uv.lock') }}
# Build the book
- name: Build the book
run: |
uv run jupyter-book build .
# Upload the book's HTML as an artifact
- name: Upload book artifact
uses: actions/upload-artifact@v4
with:
name: book-html-${{ github.event.pull_request.number }}
path: "_build/html"
retention-days: 7
# Post comment with artifact link
- name: Comment PR
uses: actions/github-script@v7
if: github.event_name == 'pull_request'
with:
script: |
const artifactUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `📚 Book preview build completed! [Download the artifact](${artifactUrl}) to view the HTML locally.`
})