name: Doc-Build-Upload

on:
  pull_request:
    branches:
      - main
  push:
    branches:
      - main

jobs:
  Build-Docs:
    runs-on: ubuntu-latest
    defaults:
      run:
        shell: bash -el {0}
    steps:
      - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
        with:
          submodules: true
          fetch-depth: 0
      - uses: conda-incubator/setup-miniconda@3b0f2504dd76ef23b6d31f291f4913fb60ab5ff3
        with:
          miniconda-version: "latest"
          activate-environment: usgscsm
          environment-file: doc_environment.yml
          auto-activate-base: false
          auto-update-conda: true

      - name: Check doc build environment
        run: |
          conda list

      - name: Build Docs
        run: |
          cd docs
          doxygen Doxyfile.in
          sphinx-build -b html source public

      - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce
        with:
          name: docs_folder
          path: docs/public/