name: gh-pages

on:
  workflow_dispatch:
    inputs:
      dryrun:
        type: boolean
        description: Dry run

jobs:
  gh-pages:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: '8.0'

      - uses: ramsey/composer-install@v1
        with:
          dependency-versions: 'highest'

      - name: Install vitepress
        run: cd docs && npm install vitepress

      - name: Build site
        run: cd docs && php refgen.php && npm run build

      - name: Deploy to GitHub Pages
        if: success()
        uses: crazy-max/ghaction-github-pages@v2
        with:
          target_branch: gh-pages
          build_dir: docs/.vitepress/dist
          dry_run: ${{ github.event.inputs.dryrun }}
          verbose: true
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
