name: Docs

on: push

jobs:
  build-n-publish:
    name: Build and publish documentation to Github
    runs-on: ubuntu-20.04

    steps:
    - uses: actions/checkout@v3
    - name: Set up Python
      uses: actions/setup-python@v4
      with:
        python-version: "3.6"
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install setuptools wheel twine rich
        pip install .[dashboard]
        pip install .[dill]
        pip install .[docs]
    - name: Build documentation
      run: |
        sphinx-versioning build -r master ./docs/ ./docs/_build/html/
    - name: Publish documentation to Github
      if: startsWith(github.ref, 'refs/tags')
      uses: peaceiris/actions-gh-pages@v3.8.0
      with:
        deploy_key: ${{ secrets.DEPLOY_GITHUB_PAGES_KEY }}
        external_repository: sybrenjansen/sybrenjansen.github.io
        publish_branch: main
        publish_dir: ./docs/_build/html/
        destination_dir: mpire
