Add version switch to docs (#457) #1019
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: Build Documentation | |
# We don't want pushes (or PRs) to gh-pages to kick anything off | |
on: | |
push: | |
branches: [main] | |
paths: | |
- tests/* | |
- hydromt/* | |
- data/* | |
- docs/* | |
- examples/* | |
- pyproject.toml | |
pull_request: | |
branches: [main] | |
paths: | |
- tests/* | |
- hydromt/* | |
- data/* | |
- docs/* | |
- examples/* | |
- pyproject.toml | |
jobs: | |
# Build docs on Linux | |
Docs: | |
timeout-minutes: 10 | |
name: linux docs | |
runs-on: ubuntu-latest | |
env: | |
DOC_VERSION: dev | |
defaults: | |
run: | |
shell: bash -l {0} | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
steps: | |
- name: Checkout source | |
uses: actions/checkout@v3 | |
- name: install tomli | |
run: pip install tomli | |
- name: Generate env spec | |
run: python make_env.py doc | |
- name: Setup environment | |
uses: conda-incubator/setup-miniconda@v2 | |
with: | |
python-version: '3.10' | |
miniforge-variant: Mambaforge | |
channels: conda-forge, defaults | |
channel-priority: strict | |
environment-file: environment.yml | |
activate-environment: hydromt | |
- name: Install hydromt | |
run: pip install . | |
- name: Build docs | |
run: | | |
make html | |
- name: Set doc version | |
run: echo "DOC_VERSION=$(python -c 'from hydromt import __version__ as v; print("dev" if "dev" in v else "v"+v.replace(".dev",""))')" >> $GITHUB_ENV | |
- name: Upload to GitHub Pages | |
if: ${{ github.event_name != 'pull_request' && !github.event.act }} | |
uses: peaceiris/[email protected] | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./docs/_build/html | |
exclude_assets: .buildinfo,_sources/*,_examples/*.ipynb | |
destination_dir: ./${{ env.DOC_VERSION }} | |
keep_files: false | |
full_commit_message: Deploy ${{ env.DOC_VERSION }} to GitHub Pages |