name: Build report document
on:
  push:
    branches: [ main ]
    paths:
      - ".github/workflows/build-sphinx-report.yml"
      - "report/**"
      - "backend/**"
jobs:
  html:
    name: "Build HTML document"
    runs-on: ubuntu-latest
    steps:
      - name: "Checkout repository"
        uses: actions/checkout@v2
      - name: "Setup Python"
        uses: actions/setup-python@v2
        with:
          python-version: 3.9
      - name: "Setup Poetry"
        uses: abatilo/actions-poetry@v2.0.0
        with:
          poetry-version: 1.1.11
      - name: "Install backend dependencies"
        working-directory: backend/
        run: poetry install --no-interaction
      - name: "Find Poetry Python environment"
        working-directory: backend/
        run: echo "pythonLocation=$(poetry env list --full-path | cut -f1 -d' ')/bin" >> $GITHUB_ENV
      - name: "Build HTML document with Sphinx"
        working-directory: report/
        run: |
          source $pythonLocation/activate
          make html
      - name: "Create a gzipped tarball of the build"
        working-directory: ${{ github.workspace }}
        run: tar -cvzf report/build/report.html.tar.gz report/build/html
      - name: "Upload build artifact"
        uses: actions/upload-artifact@v2
        with:
          name: "report.html.tar.gz"
          path: "report/build/report.html.tar.gz"