name: VitePress Deploy

on:
  push:
    branches:
      - main
    paths:
      - 'docs/**'
      - '.github/workflows/vitepress-deploy.yml'
  workflow_dispatch:
permissions:
  contents: write

jobs:
  deploy:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

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

      - name: Install pnpm
        run: corepack enable pnpm

      - name: Install dependencies (docs)
        run: cd docs && pnpm install

      - name: Build VitePress site
        run: cd docs && pnpm run docs:build

      - name: Deploy 🚀
        uses: JamesIves/github-pages-deploy-action@v4
        with:
          folder: docs/.vitepress/dist
