name: Deploy docs

on:
  push:
    branches: [ main ]
  workflow_dispatch:

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

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

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - uses: actions/setup-python@v5
        with:
          python-version: "3.12"

      - name: Install docs deps
        run: |
          python -m pip install -U pip
          pip install -e ".[docs]"

      - name: Build Sphinx
        run: |
          sphinx-build -b html sphinx sphinx/_build/html

      - name: Upload Pages artifact
        uses: actions/upload-pages-artifact@v3
        with:
          path: sphinx/_build/html

  deploy:
    needs: build
    runs-on: ubuntu-latest
    environment:
      name: github-pages
    steps:
      - id: deployment
        uses: actions/deploy-pages@v4