-
Notifications
You must be signed in to change notification settings - Fork 15
108 lines (95 loc) · 3.42 KB
/
docs.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
name: Build Documentation
on:
workflow_dispatch:
push:
branches: [main]
paths:
- tests/*
- hydromt_wflow/*
- docs/*
- examples/*
- pyproject.toml
pull_request:
branches: [main]
paths:
- tests/*
- hydromt_wflow/*
- docs/*
- examples/*
- pyproject.toml
jobs:
# Build docs on Linux
Docs:
defaults:
run:
shell: bash -l {0}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest" ] #, "macos-latest", "windows-latest"]
python-version: ['3.11']
include:
- os: ubuntu-latest
label: linux-64
prefix: /usr/share/miniconda3/envs/hydromt_wflow
name: ${{ matrix.label }}
runs-on: ${{ matrix.os }}
timeout-minutes: 30
steps:
- name: Checkout source
uses: actions/checkout@v3
- name: Generate env yaml
run: |
pip install tomli
python make_env.py doc -p ${{ matrix.python-version }}.* -n hydromt_wflow
- name: Load cache
id: cache
uses: actions/cache/restore@v3
with:
path: |
/usr/share/miniconda3
~/pycache
./docs/_build
# the below two settings mean we'll alway srestore the cache
# but the cache hit output can tell us if we have to update afterwards
key: docs-${{ hashFiles('environment.yml') }}
restore-keys: |
docs
- name: Failed cache restore
if: steps.cache.outputs.cache-matched-key == ''
run: |
echo "Failed to restore any cache. exiting..."
exit 1
# by avoiding the mamba setup stage by loading it from cache instead we save
# a lot of setup time, but we do have to do our own PATH management
# hence the exports
- name: Update environment
if: steps.cache.outputs.cache-hit != 'true'
run: |
export PATH=/usr/share/miniconda3/bin:$PATH
mamba env update -n hydromt_wflow -f environment.yml
# - name: Install HydroMT-core dev
# run: |
# export PATH=/usr/share/miniconda3/bin:$PATH
# mamba run -n hydromt_wflow python -m pip install git+https://github.com/Deltares/hydromt.git@main --user
- name: Generate dummy docs
if: ${{ github.event_name == 'pull_request' }}
run: |
export PATH=/usr/share/miniconda3/bin:$PATH
PYTHONPYCACHEPREFIX=~/pycache mamba run -n hydromt_wflow sphinx-build ./docs ./docs/_build -b dummy
- name: Generate docs
if: ${{ github.event_name != 'pull_request' && !github.event.act }}
run: |
export PATH=/usr/share/miniconda3/bin:$PATH
PYTHONPYCACHEPREFIX=~/pycache mamba run -n hydromt_wflow sphinx-build -M html ./docs ./docs/_build
echo "DOC_VERSION=$(mamba run -n hydromt_wflow python -c 'from hydromt_wflow 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'}}
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