name: "Build and deploy Github pages"

on:
  push:
    branches: master

jobs:

  build-and-deploy:

    name: "Build and deploy Sphinx documentation"
    runs-on: ubuntu-latest

    steps:

      - name: "Checkout the repository"
        uses: actions/checkout@v2
        with:
          persist-credentials: false
          submodules: true

      - name: "Set up Python"
        uses: actions/setup-python@v2
        with:
          python-version: "3.10"

      - name: "Install Python dependencies"
        run: |
          pip3 install setuptools nox

      - name: "Build Sphinx Doc"
        run: |
          nox -s gendoc

      - name: "Deploy Github Pages"
        uses: JamesIves/github-pages-deploy-action@3.7.1
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          BRANCH: gh-pages
          FOLDER: build/html/
