name: gen-docs

on:
  push:
    tags:
      - '*'

# on:
#   workflow_dispatch:

jobs:
  docs:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: true
      matrix:
        php: [8.0]
    name: Docs P${{ matrix.php }}

    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          fetch-depth: 0
          persist-credentials: false

      - name: Cache
        uses: actions/cache@v2
        with:
          path: ~/.composer/cache/files
          key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}

      - name: Composer
        run: composer update --prefer-dist --no-interaction --no-progress

      - name: Generate
        run: vendor/bin/doctum.php update doctum.php -v

      - name: Deploy 🚀
        uses: JamesIves/github-pages-deploy-action@3.7.1
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          BRANCH: gh-pages # The branch the action should deploy to.
          FOLDER: docs # The folder the action should deploy.
          CLEAN: true # Automatically remove deleted files from the deploy branch
