name: Deploy Website

on:
  push:
    branches:
      - main
    paths:
      - website/**
      - assets/**
      - examples/**
      - scripts/build_website.py
      - mkdocs.yaml
      - .github/workflows/deploy-website.yaml

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

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

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      -
        name: Checkout
        uses: actions/checkout@v4
      -
        name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: "3.13"
      -
        name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install mkdocs
          pip install mkdocs-material
          pip install mkdocs-panzoom-plugin
      -
        name: Build website
        run: python ./scripts/build_website.py
      -
        name: Upload pages artifact
        uses: actions/upload-pages-artifact@v3
        with:
          path: ./website/build/

  deploy:
    needs: build
    runs-on: ubuntu-latest
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    steps:
      -
        name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v4
