forked from NOAA-EMC/xregrid
-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (74 loc) · 2.53 KB
/
Copy pathdocs.yml
File metadata and controls
85 lines (74 loc) · 2.53 KB
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
name: Documentation
on:
push:
branches:
- main
- master
pull_request:
branches:
- main
- master
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Micromamba
uses: mamba-org/setup-micromamba@v2
with:
environment-file: environment.yml
init-shell: bash
cache-environment: true
post-cleanup: 'all'
- name: Install documentation dependencies
shell: bash -l {0}
run: |
micromamba run -n xregrid-env pip install zensical mkdocs-gallery mkdocs-autorefs mkdocstrings mkdocstrings-python matplotlib cartopy pooch
- name: Install package
shell: bash -l {0}
run: |
micromamba run -n xregrid-env pip install -e .
- name: Pre-fetch tutorial data
shell: bash -l {0}
run: |
# Pre-download tutorial datasets used in examples to avoid network timeouts during doc build
# (Aero Protocol: Robust CI)
for i in {1..5}; do
micromamba run -n xregrid-env python -c "import xarray as xr; \
datasets = ['rasm', 'air_temperature', 'eraint_uvz', 'ROMS_example']; \
[xr.tutorial.open_dataset(name) for name in datasets]" && break || sleep 30;
done
- name: Build documentation
shell: bash -l {0}
run: |
# Workaround for Python 3.14 compatibility with mkdocs-gallery
# ast.Str was removed in 3.14, so we monkeypatch it if necessary
export PYTHONPATH=$PYTHONPATH:$(pwd)/src
micromamba run -n xregrid-env python -c "import ast; \
ast.Str = getattr(ast, 'Str', ast.Constant); \
ast.Num = getattr(ast, 'Num', ast.Constant); \
ast.Bytes = getattr(ast, 'Bytes', ast.Constant); \
ast.NameConstant = getattr(ast, 'NameConstant', ast.Constant); \
import subprocess; subprocess.run(['zensical', 'build', '--clean'], check=True)"
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./site
deploy:
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4