name: Deploy documentation

on:
    push:
        branches: [develop]
    workflow_dispatch: {}

permissions: {}

concurrency:
    group: "pages"
    cancel-in-progress: false

jobs:
    build:
        name: GitHub Pages
        runs-on: ubuntu-24.04
        steps:
            - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
              with:
                  persist-credentials: false

            - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5
              with:
                  package_json_file: package.json
            - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
              with:
                  cache: "pnpm"
                  cache-dependency-path: pnpm-lock.yaml
                  node-version: "lts/*"

            - name: Fetch layered build
              run: ./scripts/layered.sh

            - name: Build docs
              run: pnpm run docs:build

            - name: Upload artifact
              uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5
              with:
                  path: ./docs/.vitepress/dist

    deploy:
        environment:
            name: github-pages
            url: ${{ steps.deployment.outputs.page_url }}
        runs-on: ubuntu-24.04
        permissions:
            pages: write
            id-token: write
        needs: build
        steps:
            - name: Deploy to GitHub Pages
              id: deployment
              uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 # v5
