Pages is now enabled on the repo (Settings → Pages → 'Build and deployment: GitHub Actions'), so the workflow can use the standard configure-pages → upload-pages-artifact → deploy-pages chain without needing the GITHUB_TOKEN to enable Pages itself. PR builds run the build job (catches mdbook breakage) but skip the deploy job, so PRs don't republish the live site.
56 lines
1.4 KiB
YAML
56 lines
1.4 KiB
YAML
name: Docs
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
tags: ["v*.*.*"]
|
|
pull_request:
|
|
branches: [main]
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
pages: write
|
|
id-token: write
|
|
|
|
# Only one Pages deploy at a time. Don't cancel a running deploy
|
|
# (otherwise we can leave the Pages site partially updated).
|
|
concurrency:
|
|
group: pages
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
build:
|
|
name: Build mdbook
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Install mdbook
|
|
run: |
|
|
mkdir -p ~/.local/bin
|
|
curl -sSL "https://github.com/rust-lang/mdBook/releases/download/v0.4.40/mdbook-v0.4.40-x86_64-unknown-linux-musl.tar.gz" \
|
|
| tar -xz -C ~/.local/bin
|
|
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
|
|
- name: Build
|
|
run: |
|
|
cd docs/book
|
|
mdbook build
|
|
- uses: actions/configure-pages@v5
|
|
- uses: actions/upload-pages-artifact@v3
|
|
with:
|
|
path: target/book
|
|
|
|
deploy:
|
|
name: Deploy to GitHub Pages
|
|
# Only deploy on pushes to main / tag pushes / manual runs.
|
|
# PR builds get the build-and-upload step but no deploy.
|
|
if: github.event_name != 'pull_request'
|
|
needs: build
|
|
runs-on: ubuntu-latest
|
|
environment:
|
|
name: github-pages
|
|
url: ${{ steps.deployment.outputs.page_url }}
|
|
steps:
|
|
- id: deployment
|
|
uses: actions/deploy-pages@v4
|