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,28 @@ jobs:
139
138
- name : Build the documentation
140
139
run : make -C doc clean all
141
140
141
+ # Upload documentation artifact
142
+ - name : Upload documentation artifact
143
+
144
+ with :
145
+ name : pygmt-docs-html
146
+ path : doc/_build/html/
147
+ if : matrix.os == 'ubuntu-latest'
148
+
149
+ deploy-docs :
150
+ name : Deploy documentation
151
+ needs : build-docs
152
+ runs-on : ubuntu-latest
153
+ if : (github.event_name == 'release' || github.event_name == 'push') && github.repository == 'GenericMappingTools/pygmt'
154
+
155
+ steps :
156
+ # Checkout current git repository
157
+ - name : Checkout
158
+
159
+ with :
160
+ # fetch all history so that setuptools-scm works
161
+ fetch-depth : 0
162
+
142
163
- name : Checkout the gh-pages branch
143
164
144
165
with :
@@ -147,7 +168,12 @@ jobs:
147
168
path : deploy
148
169
# Download the entire history
149
170
fetch-depth : 0
150
- if : (github.event_name == 'release' || github.event_name == 'push') && (matrix.os == 'ubuntu-latest')
171
+
172
+ - name : Download documentation artifact
173
+
174
+ with :
175
+ name : pygmt-docs-html
176
+ path : pygmt-docs-html
151
177
152
178
- name : Push the built HTML to gh-pages
153
179
run : |
@@ -159,10 +185,10 @@ jobs:
159
185
version=dev
160
186
fi
161
187
echo "Deploying version: $version"
162
- # Make the new commit message. Needs to happen before cd into deploy
163
- # to get the right commit hash.
188
+ # Make the new commit message. Needs to happen before cd into deploy to get
189
+ # the right commit hash.
164
190
message="Deploy $version from $(git rev-parse --short HEAD)"
165
- cd deploy
191
+ cd deploy/
166
192
# Create some files in the root directory.
167
193
# .nojekyll: Need to have this file so that GitHub doesn't try to run Jekyll
168
194
touch .nojekyll
@@ -174,7 +200,7 @@ jobs:
174
200
echo -e "\nRemoving old files from previous builds of ${version}:"
175
201
rm -rvf ${version}
176
202
echo -e "\nCopying HTML files to ${version}:"
177
- cp -Rvf ../doc/_build/ html/ ${version}/
203
+ cp -Rvf ../pygmt-docs- html/ ${version}/
178
204
# If this is a new release, update the link from /latest to it
179
205
if [[ "${version}" != "dev" ]]; then
180
206
echo -e "\nSetup link from ${version} to 'latest'."
@@ -188,19 +214,17 @@ jobs:
188
214
# Configure git to be the GitHub Actions account
189
215
git config user.email "github-actions[bot]@users.noreply.github.com"
190
216
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
217
+ # If this is a dev build and the last commit was from a dev build (detect if
218
+ # "dev" was in the previous commit message), reuse the same commit.
194
219
if [[ "${version}" == "dev" && `git log -1 --format='%s'` == *"dev"* ]]; then
195
220
echo -e "\nAmending last commit:"
196
221
git commit --amend --reset-author -m "$message"
197
222
else
198
223
echo -e "\nMaking a new commit:"
199
224
git commit -m "$message"
200
225
fi
201
- # Make the push quiet just in case there is anything that could leak
202
- # sensitive information.
226
+ # Make the push quiet just in case there is anything that could leak sensitive
227
+ # information.
203
228
echo -e "\nPushing changes to gh-pages."
204
229
git push -fq origin gh-pages 2>&1 >/dev/null
205
230
echo -e "\nFinished uploading generated files."
206
- if : (github.event_name == 'release' || github.event_name == 'push') && (matrix.os == 'ubuntu-latest')
0 commit comments