name: Deploy VitePress Docs to Pages

on:
  push:
    branches: [master]
    paths:
      - .github/workflows/deploy-docs.yml
      - docs/**
      - package.json
      - homepage/**
      - scripts/build-site.sh

  workflow_dispatch:

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

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

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v6
        with:
          fetch-depth: 0

      - name: Setup Bun
        uses: oven-sh/setup-bun@v2

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

      - name: Install dependencies
        run: bun install

      - name: Build with VitePress and custom homepage
        run: bun run build

      - name: Upload artifact
        uses: actions/upload-pages-artifact@v5
        with:
          path: dist

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