name: Deploy Astron Agent Site

on:
  push:
    branches:
      - main
      - master
    paths:
      - "docs/**"
      - ".github/workflows/deploy-pages.yml"
  workflow_dispatch:

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

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

jobs:
  deploy:
    runs-on: ubuntu-latest
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: 20

      - name: Setup Pages
        uses: actions/configure-pages@v5

      - name: Install dependencies
        working-directory: docs
        run: npm install

      - name: Build docs site
        working-directory: docs
        env:
          DOCS_BASE: /astron-agent/
        run: npm run docs:build

      - name: Add .nojekyll
        run: touch docs/.vitepress/dist/.nojekyll

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

      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v4
