name: Docs

on:
  push:
    branches: [main]
    paths:
      - "docs-site/**"
  pull_request:
    branches: [main]
    paths:
      - "docs-site/**"

permissions:
  contents: read

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

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

      - uses: astral-sh/setup-uv@v5
        with:
          enable-cache: true

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

      - uses: actions/setup-node@v4
        with:
          node-version: "20"
          cache: "npm"
          cache-dependency-path: docs-site/package-lock.json

      - name: Install Python dependencies
        run: uv sync --extra dev

      - name: Install Node dependencies
        working-directory: docs-site
        run: npm ci

      - name: Build docs
        working-directory: docs-site
        run: npm run build
