1
- # Build and deploy documentation
1
+ # Build and deploy documentation.
2
2
#
3
3
# This workflow builds the documentation on Linux/macOS/Windows.
4
4
#
5
- # It is run on every commit to the main and pull request branches, and also
6
- # when a new release is published.
7
- # In draft pull requests, only the job on Linux is triggered to save on
8
- # Continuous Integration resources.
5
+ # It is run on every commit to the main and pull request branches, and also when a new
6
+ # release is published. In draft pull requests, only the job on Linux is triggered to
7
+ # save on Continuous Integration resources.
9
8
#
10
9
# On the main branch, the workflow also handles the documentation deployment:
11
10
#
12
- # * Updating the development documentation by pushing the built HTML pages
13
- # from the main branch onto the dev folder of the gh-pages branch.
11
+ # * Updating the development documentation by pushing the built HTML pages from the main
12
+ # branch onto the dev folder of the gh-pages branch.
14
13
# * Updating the latest documentation link to the new release.
15
14
#
16
15
name : Docs
@@ -44,7 +43,7 @@ concurrency:
44
43
cancel-in-progress : ${{ github.ref != 'refs/heads/main' }}
45
44
46
45
jobs :
47
- docs :
46
+ build- docs :
48
47
name : ${{ matrix.os }}
49
48
runs-on : ${{ matrix.os }}
50
49
if : github.repository == 'GenericMappingTools/pygmt'
@@ -139,6 +138,27 @@ jobs:
139
138
- name : Build the documentation
140
139
run : make -C doc clean all
141
140
141
+ - name : Upload HMTL documentation artifact
142
+ uses : actions/upload-artifact@v4.5.0
143
+ with :
144
+ name : pygmt-docs-html
145
+ path : doc/_build/html/
146
+ if : matrix.os == 'ubuntu-latest'
147
+
148
+ deploy-docs :
149
+ name : Deploy documentation
150
+ needs : build-docs
151
+ runs-on : ubuntu-latest
152
+ if : (github.event_name == 'release' || github.event_name == 'push') && github.repository == 'GenericMappingTools/pygmt'
153
+
154
+ steps :
155
+ # Checkout current git repository
156
+ - name : Checkout
157
+ uses : actions/checkout@v4.2.2
158
+ with :
159
+ # fetch all history so that setuptools-scm works
160
+ fetch-depth : 0
161
+
142
162
- name : Checkout the gh-pages branch
143
163
uses : actions/checkout@v4.2.2
144
164
with :
@@ -147,7 +167,12 @@ jobs:
147
167
path : deploy
148
168
# Download the entire history
149
169
fetch-depth : 0
150
- if : (github.event_name == 'release' || github.event_name == 'push') && (matrix.os == 'ubuntu-latest')
170
+
171
+ - name : Download HTML documentation artifact
172
+ uses : actions/download-artifact@v4.1.8
173
+ with :
174
+ name : pygmt-docs-html
175
+ path : pygmt-docs-html
151
176
152
177
- name : Push the built HTML to gh-pages
153
178
run : |
@@ -159,10 +184,10 @@ jobs:
159
184
version=dev
160
185
fi
161
186
echo "Deploying version: $version"
162
- # Make the new commit message. Needs to happen before cd into deploy
163
- # to get the right commit hash.
187
+ # Make the new commit message. Needs to happen before cd into deploy to get
188
+ # the right commit hash.
164
189
message="Deploy $version from $(git rev-parse --short HEAD)"
165
- cd deploy
190
+ cd deploy/
166
191
# Create some files in the root directory.
167
192
# .nojekyll: Need to have this file so that GitHub doesn't try to run Jekyll
168
193
touch .nojekyll
@@ -174,7 +199,7 @@ jobs:
174
199
echo -e "\nRemoving old files from previous builds of ${version}:"
175
200
rm -rvf ${version}
176
201
echo -e "\nCopying HTML files to ${version}:"
177
- cp -Rvf ../doc/_build/ html/ ${version}/
202
+ cp -Rvf ../pygmt-docs- html/ ${version}/
178
203
# If this is a new release, update the link from /latest to it
179
204
if [[ "${version}" != "dev" ]]; then
180
205
echo -e "\nSetup link from ${version} to 'latest'."
@@ -188,19 +213,17 @@ jobs:
188
213
# Configure git to be the GitHub Actions account
189
214
git config user.email "github-actions[bot]@users.noreply.github.com"
190
215
git config user.name "github-actions[bot]"
191
- # If this is a dev build and the last commit was from a dev build
192
- # (detect if "dev" was in the previous commit message), reuse the
193
- # same commit
216
+ # If this is a dev build and the last commit was from a dev build (detect if
217
+ # "dev" was in the previous commit message), reuse the same commit.
194
218
if [[ "${version}" == "dev" && `git log -1 --format='%s'` == *"dev"* ]]; then
195
219
echo -e "\nAmending last commit:"
196
220
git commit --amend --reset-author -m "$message"
197
221
else
198
222
echo -e "\nMaking a new commit:"
199
223
git commit -m "$message"
200
224
fi
201
- # Make the push quiet just in case there is anything that could leak
202
- # sensitive information.
225
+ # Make the push quiet just in case there is anything that could leak sensitive
226
+ # information.
203
227
echo -e "\nPushing changes to gh-pages."
204
228
git push -fq origin gh-pages 2>&1 >/dev/null
205
229
echo -e "\nFinished uploading generated files."
206
- if : (github.event_name == 'release' || github.event_name == 'push') && (matrix.os == 'ubuntu-latest')
0 commit comments