name: Module documentation
on: [push, pull_request]
jobs:
  moduledocs:
    runs-on: ubuntu-latest
    steps:
      - name: Check out repository code
        uses: actions/checkout@v2
      - uses: actions/cache@v2
        id: cache-id
        with:
          path: ${{ runner.temp }}/cache-docs
          key: ${{ runner.os }}-cache-build-docs-key-v1.0
      - uses: airvzxf/cache-anything-new-action@60f610a30a315bf6b4dca9d4c5c2abc501d95d65
        with:
          script: 'install_docs_deps.sh'
          is_cached: ${{ steps.cache-id.outputs.cache-hit }}
          cache: ${{ runner.temp }}/cache-docs
          snapshot: '/'
          exclude: '/boot /data /dev /mnt /proc /run /sys'
      - name: Compile documentation
        run: |
          cd ${{ github.workspace }}/docs
          python3 build.py
      - name: Archive documentation as artifact
        uses: actions/upload-artifact@v2
        with:
          name: moduledocs
          path: ${{github.workspace}}/docs/docs.pdf
