Skip to content

Centralize tool versions and improve build consistency #19

Centralize tool versions and improve build consistency

Centralize tool versions and improve build consistency #19

Workflow file for this run

name: Build and Deploy mdBook
# Tool versions are managed in versions.toml at the repository root.
# To update mdbook or plugin versions, edit versions.toml and the CI will automatically use them.
on:
push:
branches: ["main"]
pull_request:
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
steps:
- name: Checkout
uses: actions/checkout@v6
# Cache Rust toolchain and cargo registry
- name: Cache Rust
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
~/.cargo/.crates.toml
~/.cargo/.crates2.json
key: ${{ runner.os }}-cargo-${{ hashFiles('versions.toml') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Install mdBook and plugins
run: |
chmod +x scripts/install-tools.sh
./scripts/install-tools.sh
- name: Build with mdBook
run: mdbook build ./better-code
# Only deploy from main branch (push or manual dispatch)
- name: Setup Pages
if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main'
id: pages
uses: actions/configure-pages@v5
- name: Upload artifact
if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main'
uses: actions/upload-pages-artifact@v4
with:
path: ./better-code/book
deploy:
if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main'
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