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

name: documentation

on:
  push:
    branches:
      - main

jobs:
  build:
    runs-on: ubuntu-24.04
    environment:
      name: github-pages
    timeout-minutes: 10
    strategy:
      matrix:
        python-version:
          - "3.12"

    steps:
    - name: Check out repository
      uses: actions/checkout@v4

    - name: Install uv
      uses: astral-sh/setup-uv@v3
      with:
        version: "0.7.4"
        enable-cache: true
        cache-dependency-glob: "uv.lock"

    - name: Set up Python ${{ matrix.python-version }}
      run: uv python install ${{ matrix.python-version }}

    - name: Create virtual environment
      run: make install-docs-env

    - name: Download data
      run: uv run bundestag download huggingface --y

    - name: Build documentation (mkdocs)
      # Ensure this produces the static site in the 'site' directory
      run: |
        uv run mkdocs build -d site

    - name: Deploy to gh-pages branch
      uses: peaceiris/actions-gh-pages@v4
      with:
        github_token: ${{ secrets.GITHUB_TOKEN }}
        publish_dir: ./site
        publish_branch: gh-pages
        # optional: set a deploy commit message
        commit_message: "docs: deploy site from CI"
