name: Publish Quarto site to GitHub Pages

on:
  push:
    branches: [ main ]

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

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Setup Quarto
        uses: quarto-dev/quarto-actions/setup@v2

      - name: Install Python and Jupyter
        uses: actions/setup-python@v5
        with:
          python-version: 3.12
          cache: pip

      - run: |
          python -m pip install --upgrade pip
          pip install griffe>=0.45.0
          pip install notebook ipykernel matplotlib brdr quartodoc
          python -m ipykernel install --user

      - name: Build quartodoc
        run: quartodoc build --config docs/_quarto.yml

      - name: Render Quarto site from subfolder
        run: quarto render docs

      - name: Deploy to GitHub Pages
        uses: peaceiris/actions-gh-pages@v3
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: docs/_site
          publish_branch: gh-pages  # branch for documentation deployment for github pages
