name: Deploy Docs

on:
  push:
    branches:
      - main
  workflow_dispatch:

jobs:
  deploy:
    runs-on: ubuntu-24.04
    concurrency:
      group: docs-${{ github.ref }}
      cancel-in-progress: true
    permissions:
      contents: read
    defaults:
      run:
        working-directory: "./docs"
    steps:
      - name: Checkout repository
        uses: actions/checkout@v6

      - name: Setup Development Environment
        uses: jdx/mise-action@v4
        with:
          working_directory: .

      - name: Install dependencies
        run: bun install

      - name: Build documentation
        run: bun run build

      - name: Deploy to Cloudflare Workers
        uses: cloudflare/wrangler-action@v3
        with:
          apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
          workingDirectory: docs
