Skip to content

Commit eef1a0b

Browse files
committed
Add the build_docs composite action to simplify the main workflow
1 parent 05fd428 commit eef1a0b

File tree

2 files changed

+85
-71
lines changed

2 files changed

+85
-71
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Build Docs
2+
description: Build the documentation
3+
inputs:
4+
os:
5+
description: 'Operating system'
6+
required: true
7+
default: 'ubuntu-latest'
8+
9+
runs:
10+
using: 'composite'
11+
steps:
12+
# Checkout current git repository
13+
- name: Checkout
14+
uses: actions/[email protected]
15+
with:
16+
# fetch all history so that setuptools-scm works
17+
fetch-depth: 0
18+
persist-credentials: false
19+
20+
- name: Get current week number of year
21+
id: date
22+
run: echo "date=$(date +%Y-W%W)" >> $GITHUB_OUTPUT # e.g., 2024-W19
23+
24+
# Install Micromamba with conda-forge dependencies
25+
- name: Setup Micromamba
26+
uses: mamba-org/[email protected]
27+
with:
28+
environment-name: pygmt
29+
cache-environment: true
30+
# environment cache is persistent for one week.
31+
cache-environment-key: micromamba-environment-${{ steps.date.outputs.date }}
32+
create-args: >-
33+
python=3.13
34+
gmt=6.5.0
35+
ghostscript=10.04.0
36+
numpy
37+
pandas
38+
xarray
39+
netCDF4
40+
packaging
41+
contextily
42+
geopandas
43+
ipython
44+
pyarrow-core
45+
rioxarray
46+
make
47+
pip
48+
python-build
49+
geodatasets
50+
myst-nb
51+
panel
52+
sphinx>=6.2
53+
sphinx-autodoc-typehints
54+
sphinx-copybutton
55+
sphinx-design
56+
sphinx-gallery
57+
sphinx_rtd_theme
58+
cairosvg
59+
sphinxcontrib-svg2pdfconverter
60+
tectonic
61+
62+
# Download cached remote files (artifacts) from GitHub
63+
- name: Download remote data from GitHub
64+
run: |
65+
# Download cached files to ~/.gmt directory and list them
66+
gh run download --name gmt-cache --dir ~/.gmt/
67+
# Change modification times of the two files, so GMT won't refresh it
68+
touch ~/.gmt/gmt_data_server.txt ~/.gmt/gmt_hash_server.txt
69+
ls -lhR ~/.gmt
70+
env:
71+
GH_TOKEN: ${{ github.token }}
72+
73+
# Install the package that we want to test
74+
- name: Install the package
75+
run: |
76+
python -m build --sdist
77+
python -m pip install dist/*
78+
79+
- name: Build the HTML documentation
80+
run: make -C doc clean html
81+
82+
- name: Build the PDF documentation
83+
run: make -C doc pdf

.github/workflows/ci_docs.yml

Lines changed: 2 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -68,78 +68,9 @@ jobs:
6868
shell: bash -l {0}
6969

7070
steps:
71-
# Checkout current git repository
72-
- name: Checkout
73-
uses: actions/[email protected]
74-
with:
75-
# fetch all history so that setuptools-scm works
76-
fetch-depth: 0
77-
persist-credentials: false
78-
79-
- name: Get current week number of year
80-
id: date
81-
run: echo "date=$(date +%Y-W%W)" >> $GITHUB_OUTPUT # e.g., 2024-W19
82-
83-
# Install Micromamba with conda-forge dependencies
84-
- name: Setup Micromamba
85-
uses: mamba-org/[email protected]
71+
- uses: ./.github/workflows/actions/build_docs/action.yml
8672
with:
87-
environment-name: pygmt
88-
cache-environment: true
89-
# environment cache is persistent for one week.
90-
cache-environment-key: micromamba-environment-${{ steps.date.outputs.date }}
91-
create-args: >-
92-
python=3.13
93-
gmt=6.5.0
94-
ghostscript=10.04.0
95-
numpy
96-
pandas
97-
xarray
98-
netCDF4
99-
packaging
100-
contextily
101-
geopandas
102-
ipython
103-
pyarrow-core
104-
rioxarray
105-
make
106-
pip
107-
python-build
108-
geodatasets
109-
myst-nb
110-
panel
111-
sphinx>=6.2
112-
sphinx-autodoc-typehints
113-
sphinx-copybutton
114-
sphinx-design
115-
sphinx-gallery
116-
sphinx_rtd_theme
117-
cairosvg
118-
sphinxcontrib-svg2pdfconverter
119-
tectonic
120-
121-
# Download cached remote files (artifacts) from GitHub
122-
- name: Download remote data from GitHub
123-
run: |
124-
# Download cached files to ~/.gmt directory and list them
125-
gh run download --name gmt-cache --dir ~/.gmt/
126-
# Change modification times of the two files, so GMT won't refresh it
127-
touch ~/.gmt/gmt_data_server.txt ~/.gmt/gmt_hash_server.txt
128-
ls -lhR ~/.gmt
129-
env:
130-
GH_TOKEN: ${{ github.token }}
131-
132-
# Install the package that we want to test
133-
- name: Install the package
134-
run: |
135-
python -m build --sdist
136-
python -m pip install dist/*
137-
138-
- name: Build the HTML documentation
139-
run: make -C doc clean html
140-
141-
- name: Build the PDF documentation
142-
run: make -C doc pdf
73+
os: ${{ matrix.os }}
14374

14475
- name: Create the HTML ZIP archive and rename the PDF file
14576
run: |

0 commit comments

Comments
 (0)