name: "sphinx"

on:
  workflow_dispatch:
  push:
    branches: ["main"]
    paths: ["docs/**", "README.md", "CHANGELOG.md"]

permissions:
  contents: "read"
  pages: "write"
  id-token: "write"

concurrency:
  group: "pages"
  cancel-in-progress: true

jobs:
  build:
    runs-on: "{{ actions_runner }}"
    steps:
      - uses: "blakeNaccarato/copier-python-workflow-setup@v0.1.0"
        with:
          python-version: "{{ python_version }}"
      - run: "python -m sphinx -T -E docs _site"
      - uses: "actions/upload-pages-artifact@v2.0.0"
  deploy:
    if: "{% raw %}${{ !(github.event_name == 'pull_request') }}{% endraw %}"
    environment:
      name: "github-pages"
      url: "{% raw %}${{ steps.deployment.outputs.page_url }}{% endraw %}"
    runs-on: "{{ actions_runner }}"
    needs: "build"
    steps:
      - id: "deployment"
        uses: "actions/deploy-pages@v2.0.3"
