name: Deploy Documentation

on:
  push:
    branches: [master]
    paths:
      - 'docs/**'
      - 'scripts/doc_generator.py'
      - 'scripts/llms_generator.py'
      - 'seeds/**'
      - '.github/workflows/docs.yml'
  pull_request:
    branches: [master]
    paths:
      - 'docs/**'
      - 'scripts/doc_generator.py'
      - 'scripts/llms_generator.py'
      - 'seeds/**'
      - '.github/workflows/docs.yml'
  workflow_dispatch:

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

concurrency:
  group: docs-${{ github.ref }}
  cancel-in-progress: true

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

      - uses: ./.github/actions/setup-env
        with:
          uv-version: "0.8.17"

      - name: Build Docs
        run: just scan seed docs docs-build

      - uses: actions/upload-pages-artifact@v3
        with:
          path: docs/_build/html

  deploy:
    needs: build
    if: github.event_name != 'pull_request'
    runs-on: ubuntu-latest
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    steps:
      - id: deployment
        uses: actions/deploy-pages@v4
