name: Documentation
on:
push:
branches: [main]
paths:
- 'docs/**'
- 'src/**'
- 'Cargo.toml'
- 'Cargo.lock'
- '.github/workflows/docs.yml'
pull_request:
branches: [main]
paths:
- 'docs/**'
- 'src/**'
- 'Cargo.toml'
- 'Cargo.lock'
- '.github/workflows/docs.yml'
env:
CARGO_TERM_COLOR: always
jobs:
docs:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache Cargo dependencies
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Build mdbook-lint
run: cargo build --release
- name: Install mdbook
run: cargo install mdbook
- name: Lint documentation
continue-on-error: true
run: |
cd docs
../target/release/mdbook-lint lint --config .mdbook-lint.toml src/
- name: Build documentation
run: |
cd docs
mdbook build
- name: Upload Pages artifact
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
uses: actions/upload-pages-artifact@v3
with:
path: docs/book
deploy:
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
needs: docs
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4