22#
33# This workflow builds the documentation on Linux/macOS/Windows.
44#
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.
98#
109# On the main branch, the workflow also handles the documentation deployment:
1110#
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.
1413# * Updating the latest documentation link to the new release.
1514#
1615name : Docs
@@ -43,6 +42,9 @@ concurrency:
4342 group : ${{ github.workflow }}-${{ github.ref }}
4443 cancel-in-progress : ${{ github.ref != 'refs/heads/main' }}
4544
45+ permissions :
46+ contents : write
47+
4648jobs :
4749 docs :
4850 name : ${{ matrix.os }}
7375 with :
7476 # fetch all history so that setuptools-scm works
7577 fetch-depth : 0
78+ persist-credentials : false
7679
7780 - name : Get current week number of year
7881 id : date
@@ -159,10 +162,11 @@ jobs:
159162 if : github.event_name == 'push' && matrix.os == 'ubuntu-latest'
160163
161164 - name : Upload the HTML ZIP archive and PDF as release assets
162- run : gh release upload ${{ github.ref_name } } doc/_build/pygmt-docs.zip doc/_build/pygmt-docs.pdf
165+ run : gh release upload ${REF_NAME } doc/_build/pygmt-docs.zip doc/_build/pygmt-docs.pdf
163166 if : github.event_name == 'release' && matrix.os == 'ubuntu-latest'
164167 env :
165168 GH_TOKEN : ${{ github.token }}
169+ REF_NAME : ${{ github.ref_name }}
166170
167171 - name : Checkout the gh-pages branch
168172 uses : actions/checkout@v4.2.2
@@ -172,6 +176,7 @@ jobs:
172176 path : deploy
173177 # Download the entire history
174178 fetch-depth : 0
179+ persist-credentials : true
175180 if : (github.event_name == 'release' || github.event_name == 'push') && (matrix.os == 'ubuntu-latest')
176181
177182 - name : Push the built HTML to gh-pages
0 commit comments