name: Deploy to Pages

on:
  push:
    branches:
      - master

permissions:
  contents: read
  pages: write
  id-token: write

concurrency:
  group: "pages"
  cancel-in-progress: true

jobs:
  deploy:
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}

    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v6
      - uses: actions/configure-pages@v5

      - name: Setup mdBook
        uses: peaceiris/actions-mdbook@v2
        with:
          mdbook-version: "0.4.52"

      - name: Build mdBook documentation
        run: cd book && mdbook build && mv ../scripts/* book/

      - name: Upload artifact
        uses: actions/upload-pages-artifact@v4
        with:
          path: "./book/book/"

      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v4
