name: Release Documentation

on:
  workflow_dispatch:
  push:
    branches:
      - main

jobs:
  release-docs:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
            fetch-depth: 0

      - uses: Swatinem/rust-cache@v2

      - run: cargo install mdbook-linkcheck
      - run: cargo install mdbook-toc
      - uses: peaceiris/actions-mdbook@v2
        with:
          mdbook-version: '0.4.12'

      - name: Build Book
        working-directory: book
        run: mdbook build

      - uses: peaceiris/actions-gh-pages@v4
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: book/booster-manual/html
          enable_jekyll: true
          publish_branch: pages
          force_orphan: true
