name: Book

on:
  push:
    branches: [master]
    paths:
      - 'book/**'
      - '.github/workflows/book.yml'
  pull_request:
    branches: [master]
    paths:
      - 'book/**'
  workflow_dispatch:

env:
  CARGO_TERM_COLOR: always

jobs:
  build-book:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Install mdBook
        uses: peaceiris/actions-mdbook@v2
        with:
          mdbook-version: 'latest'
      - name: Build book
        run: mdbook build book
      - name: Test book
        run: mdbook test book
