name: Publish new Docs

on:
  push:
    tags:
      - 'v*'
  workflow_run:
    workflows: ["Python Tests", "Publish to PyPI"]
    types:
      - completed
    branches: [main]

jobs:
  docs:
    name: Build documentation
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Set up Python
        uses: actions/setup-python@v2
        with:
          python-version: "3.10"
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install -r requirements.txt
          pip install -r requirements-dev.txt
          pip install sphinx sphinx-rtd-theme sphinx-autodoc-typehints sphinx-copybutton myst-parser
      - name: Build documentation
        run: |
          cd docs
          make html
      - name: Archive documentation
        uses: actions/upload-artifact@v2
        with:
          name: documentation
          path: docs/build/html/
