Skip to content

Commit c0b595c

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

File tree

2 files changed

+77
-63
lines changed

2 files changed

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

.github/workflows/ci_docs.yml

Lines changed: 2 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -76,70 +76,9 @@ jobs:
7676
fetch-depth: 0
7777
persist-credentials: false
7878

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/setup-micromamba@v2.0.4
79+
- uses: ./.github/workflows/actions/build_docs/action.yml
8680
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
81+
os: ${{ matrix.os }}
14382

14483
- name: Create the HTML ZIP archive and rename the PDF file
14584
run: |

0 commit comments

Comments
 (0)