name: Build documentation

on:
  workflow_dispatch:
  release:
    types: [published]

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: ['3.10']

    steps:
      - uses: actions/checkout@v2

      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v2
        with:
          python-version: ${{ matrix.python-version }}

      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install pdoc
          if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
      - name: Build docs
        run: |
          chmod +x ./scripts/build_documentation.sh
          bash ./scripts/build_documentation.sh
      - name: Deploy
        uses: JamesIves/github-pages-deploy-action@4.1.4
        with:
          branch: documentation
          folder: ./documentation
