name: docs

on: [push, pull_request]

jobs:
  docs-linux:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2

    - name: Build HTML docs
      uses: ammaraskar/sphinx-action@master
      with:
        docs-folder: "docs/"

    - name: Build PDF docs
      if: ${{ github.event_name == 'pull_request' }}
      uses: ammaraskar/sphinx-action@master
      with:
        docs-folder: "docs/"
        pre-build-command: "apt-get update -y && apt-get install -y latexmk texlive-latex-recommended texlive-latex-extra texlive-fonts-recommended"
        build-command: "make latexpdf"

# Docs workflow
#
# Ensures that the docs can be built with sphinx.
# - On every push and PR, checks the HTML documentation builds on linux.
# - On every PR and tag, checks the documentation builds as a PDF on linux.

name: docs

on: [push, pull_request]

jobs:
  html:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2

    - name: Build HTML docs
      uses: ammaraskar/sphinx-action@master
      with:
        docs-folder: "docs/"

  pdf:
    if: |
      github.event_name == 'pull_request' ||
      startsWith(github.ref, 'refs/tags/')
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2

    - name: Build PDF docs
      uses: ammaraskar/sphinx-action@master
      with:
        docs-folder: "docs/"
        pre-build-command: "apt-get update -y && apt-get install -y latexmk texlive-latex-recommended texlive-latex-extra texlive-fonts-recommended"
        build-command: "make latexpdf"

    - uses: actions/upload-artifact@v2
      if: startsWith(github.ref, 'refs/tags')
      with:
        name: Documentation
        path: docs/_build/latex/*.pdf
        retention-days: 7

Split html and pdf into separate jobs
CI:GHA: Split html and pdf into separate jobs

And store pdf as an artifact when a new tag is pushed.
