---
name: Deploy docs
on:  # yamllint disable-line rule:truthy
  push:
    branches: [main]
  workflow_dispatch:

permissions: {}

jobs:
  build-docs:
    runs-on: ubuntu-latest

    # Grant GITHUB_TOKEN the permissions required to make a gh-pages deployment
    permissions:
      contents: write  # to let mkdocs write the new docs
      pages: write     # to deploy to Pages
      id-token: write  # allow to generate an OpenID Connect (OIDC) token

    steps:
      # https://github.com/actions/checkout
      - name: Checkout
        uses: actions/checkout@v6
        with:
          fetch-depth: 0  # otherwise, you will fail to push refs to dest repo

      - name: Configure git for the bot
        # Gives the bot that commits to gh-pages a name & email address
        # so that the commits have an author in the commit log.
        run: |
          git config user.name github-actions[bot]
          git config user.email github-actions[bot]@users.noreply.github.com

      # https://github.com/astral-sh/setup-uv
      - name: Install uv
        uses: astral-sh/setup-uv@v7
        with:
          python-version: 3.13
          enable-cache: true
          cache-dependency-glob: "uv.lock"

      # https://github.com/actions/setup-python
      - name: Set up Python
        uses: actions/setup-python@v6
        with:
          python-version: 3.13

      - name: Install just
        run: |
          uv tool install rust-just

      - name: Install dependencies
        run: uv sync --dev --no-progress

      - name: Generate schema documentation
        run: |
          uv run mkdocs gh-deploy
