name: docs
on:
push:
branches: [main]
paths: ["docs/**", "src/**", ".github/workflows/docs.yml"]
pull_request:
branches: [main]
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
cargo-doc:
name: cargo-doc
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Build docs
run: cargo rustdoc --all-features -- --deny warnings
mdbook:
name: mdbook
runs-on: ubuntu-latest
continue-on-error: true
permissions:
contents: read
actions: read
steps:
- uses: actions/checkout@v4
- name: Check for book.toml
id: check
run: |
if [ -f "docs/book.toml" ]; then
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
fi
- name: Install mdbook
if: steps.check.outputs.exists == 'true'
uses: taiki-e/install-action@v2
with:
tool: mdbook
- name: Build mdbook
if: steps.check.outputs.exists == 'true'
run: mdbook build docs/
- name: Upload Pages artifact
if: steps.check.outputs.exists == 'true' && github.ref == 'refs/heads/main'
uses: actions/upload-pages-artifact@v3
with:
path: ./docs/book
pages-deploy:
name: pages-deploy
runs-on: ubuntu-latest
needs: mdbook
if: github.ref == 'refs/heads/main'
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Configure Pages
uses: actions/configure-pages@v5
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4