name: Deploy

on:
  workflow_call:
  workflow_dispatch:

jobs:
  deploy:
    runs-on: ubuntu-24.04-arm
    if: github.event.repository.fork == false
    environment:
      name: github-pages
    permissions:
      id-token: write
      pages: write
    steps:
      - uses: actions/checkout@v7
      - uses: gradle/actions/setup-gradle@v6
        with:
          cache-read-only: true
      - name: Prepare API documentation
        run: ./gradlew dokkaGenerate
      - name: Build Site
        run: |
          # Don't cache it to track updates.
          pip install mkdocs-material
          mkdocs build
      - uses: actions/upload-pages-artifact@v5
        with:
          path: site
      - uses: actions/deploy-pages@v5
