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
#
@@ -42,11 +42,10 @@ concurrency:
42
42
group : ${{ github.workflow }}-${{ github.ref }}
43
43
cancel-in-progress : ${{ github.ref != 'refs/heads/main' }}
44
44
45
- permissions :
46
- contents : write
45
+ permissions : {}
47
46
48
47
jobs :
49
- docs :
48
+ build- docs :
50
49
name : ${{ matrix.os }}
51
50
runs-on : ${{ matrix.os }}
52
51
if : github.repository == 'GenericMappingTools/pygmt'
@@ -168,6 +167,30 @@ jobs:
168
167
GH_TOKEN : ${{ github.token }}
169
168
REF_NAME : ${{ github.ref_name }}
170
169
170
+ - name : Upload HMTL documentation artifact
171
+
172
+ with :
173
+ name : pygmt-docs-html
174
+ path : doc/_build/html/
175
+ if : matrix.os == 'ubuntu-latest'
176
+
177
+ deploy-docs :
178
+ name : Deploy documentation
179
+ needs : build-docs
180
+ runs-on : ubuntu-latest
181
+ if : (github.event_name == 'release' || github.event_name == 'push') && github.repository == 'GenericMappingTools/pygmt'
182
+ permissions :
183
+ contents : write
184
+
185
+ steps :
186
+ # Checkout current git repository
187
+ - name : Checkout
188
+
189
+ with :
190
+ # fetch all history so that setuptools-scm works
191
+ fetch-depth : 0
192
+ persist-credentials : false
193
+
171
194
- name : Checkout the gh-pages branch
172
195
173
196
with :
@@ -177,7 +200,12 @@ jobs:
177
200
# Download the entire history
178
201
fetch-depth : 0
179
202
persist-credentials : true
180
- if : (github.event_name == 'release' || github.event_name == 'push') && (matrix.os == 'ubuntu-latest')
203
+
204
+ - name : Download HTML documentation artifact
205
+
206
+ with :
207
+ name : pygmt-docs-html
208
+ path : pygmt-docs-html
181
209
182
210
- name : Push the built HTML to gh-pages
183
211
run : |
@@ -189,10 +217,10 @@ jobs:
189
217
version=dev
190
218
fi
191
219
echo "Deploying version: $version"
192
- # Make the new commit message. Needs to happen before cd into deploy
193
- # to get the right commit hash.
220
+ # Make the new commit message. Needs to happen before cd into deploy to get
221
+ # the right commit hash.
194
222
message="Deploy $version from $(git rev-parse --short HEAD)"
195
- cd deploy
223
+ cd deploy/
196
224
# Create some files in the root directory.
197
225
# .nojekyll: Need to have this file so that GitHub doesn't try to run Jekyll
198
226
touch .nojekyll
@@ -204,7 +232,7 @@ jobs:
204
232
echo -e "\nRemoving old files from previous builds of ${version}:"
205
233
rm -rvf ${version}
206
234
echo -e "\nCopying HTML files to ${version}:"
207
- cp -Rvf ../doc/_build/ html/ ${version}/
235
+ cp -Rvf ../pygmt-docs- html/ ${version}/
208
236
# If this is a new release, update the link from /latest to it
209
237
if [[ "${version}" != "dev" ]]; then
210
238
echo -e "\nSetup link from ${version} to 'latest'."
@@ -218,19 +246,17 @@ jobs:
218
246
# Configure git to be the GitHub Actions account
219
247
git config user.email "github-actions[bot]@users.noreply.github.com"
220
248
git config user.name "github-actions[bot]"
221
- # If this is a dev build and the last commit was from a dev build
222
- # (detect if "dev" was in the previous commit message), reuse the
223
- # same commit
249
+ # If this is a dev build and the last commit was from a dev build (detect if
250
+ # "dev" was in the previous commit message), reuse the same commit.
224
251
if [[ "${version}" == "dev" && `git log -1 --format='%s'` == *"dev"* ]]; then
225
252
echo -e "\nAmending last commit:"
226
253
git commit --amend --reset-author -m "$message"
227
254
else
228
255
echo -e "\nMaking a new commit:"
229
256
git commit -m "$message"
230
257
fi
231
- # Make the push quiet just in case there is anything that could leak
232
- # sensitive information.
258
+ # Make the push quiet just in case there is anything that could leak sensitive
259
+ # information.
233
260
echo -e "\nPushing changes to gh-pages."
234
261
git push -fq origin gh-pages 2>&1 >/dev/null
235
262
echo -e "\nFinished uploading generated files."
236
- if : (github.event_name == 'release' || github.event_name == 'push') && (matrix.os == 'ubuntu-latest')
0 commit comments