name: Deploy to GitHub Pages
on:
  push:
  pull_request:
  workflow_dispatch:
permissions:
  contents: read
  pages: write
  id-token: write
concurrency:
  group: "pages"
  cancel-in-progress: true
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: pnpm/action-setup@v2
        with:
          version: 7
          run_install: false
      - uses: actions/setup-node@v3
        with:
          node-version: 16
          cache: "pnpm"
      - name: Install Depend
        run: pnpm install
      - name: Build Pages
        run: pnpm build
      - name: Upload Artifact
        uses: actions/upload-pages-artifact@v1
        with:
          path: ./docs/.vitepress/dist
  deploy:
    runs-on: ubuntu-latest
    needs: build
    if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    steps:
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v1
