name: Deploy mdBook site to Pages
env:
CARGO_TERM_COLOR: always
RUST_TOOLCHAIN: stable
on:
push:
branches: ["main"]
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
env:
MDBOOK_VERSION: 0.4.48
MDBOOK_GRAPHVIZ_VERSION: 0.2.1
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{env.RUST_TOOLCHAIN}}
- uses: Swatinem/rust-cache@v2
with:
env-vars: "RUST_TOOLCHAIN=${{env.RUST_TOOLCHAIN_MSRV}}"
- name: Generate Rust Docs
env:
RUSTDOCFLAGS: "-D rustdoc::broken_intra_doc_links"
run: cargo doc --all-features --no-deps
- name: Install Graphviz
run: sudo apt-get install graphviz
- name: Install mdBook
run: |
curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf -y | sh
rustup update
cargo install --version ${MDBOOK_VERSION} mdbook 2>/dev/null || true
cargo install --version ${MDBOOK_GRAPHVIZ_VERSION} mdbook-graphviz 2>/dev/null || true
- name: Setup Pages
id: pages
uses: actions/configure-pages@v4
- name: Build with mdBook
working-directory: ./docs/book
run: mdbook build
- name: Create artifact
working-directory: ./docs
run: |
mkdir -p www/book
cp -r book/book/* www/book
mkdir -p www/docs
cp -r ../target/doc/* www/docs
mkdir -p www/static
cp -r ./static/* www/static
cp index.html www/index.html
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./docs/www
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4