Skip to content

Commit 2a88f73

Browse files
authored
Migrate documentation deployment from Travis CI to GitHub Actions (#713)
* Migrate documentation deployment from Travis CI to GitHub Actions * Update README, MAINTENANCE, CONTRIBUTING and remove TravisCI settings
1 parent 8804efe commit 2a88f73

File tree

5 files changed

+75
-102
lines changed

5 files changed

+75
-102
lines changed

.github/workflows/ci_tests.yaml

+64
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77
push:
88
branches: [ master ]
99
pull_request:
10+
release:
11+
types:
12+
- published
1013
# Schedule daily tests
1114
schedule:
1215
- cron: '0 0 * * *'
@@ -138,3 +141,64 @@ jobs:
138141
file: ./coverage.xml # optional
139142
env_vars: OS,PYTHON
140143
fail_ci_if_error: true
144+
145+
- name: Checkout the gh-pages branch
146+
uses: actions/checkout@28c7f3d2b5162b5ddd3dfd9a45aa55eaf396478b
147+
with:
148+
ref: gh-pages
149+
# Checkout to this folder instead of the current one
150+
path: deploy
151+
# Download the entire history
152+
fetch-depth: 0
153+
if: (github.event_name == 'release' || github.event_name == 'push') && (matrix.os == 'ubuntu-latest') && (matrix.python-version == '3.9')
154+
155+
- name: Push the built HTML to gh-pages
156+
run: |
157+
# Detect if this is a release or from the master branch
158+
if [[ "${GITHUB_EVENT_NAME}" == "release" ]]; then
159+
# Get the tag name without the "refs/tags/" part
160+
version="${GITHUB_REF#refs/*/}"
161+
else
162+
version=dev
163+
fi
164+
echo "Deploying version: $version"
165+
# Make the new commit message. Needs to happen before cd into deploy
166+
# to get the right commit hash.
167+
message="Deploy $version from $(git rev-parse --short HEAD)"
168+
cd deploy
169+
# Need to have this file so that Github doesn't try to run Jekyll
170+
touch .nojekyll
171+
# Delete all the files and replace with our new set
172+
echo -e "\nRemoving old files from previous builds of ${version}:"
173+
rm -rvf ${version}
174+
echo -e "\nCopying HTML files to ${version}:"
175+
cp -Rvf ../doc/_build/html/ ${version}/
176+
# If this is a new release, update the link from /latest to it
177+
if [[ "${version}" != "dev" ]]; then
178+
echo -e "\nSetup link from ${version} to 'latest'."
179+
rm -f latest
180+
ln -sf ${version} latest
181+
fi
182+
# Stage the commit
183+
git add -A .
184+
echo -e "\nChanges to be applied:"
185+
git status
186+
# Configure git to be the GitHub Actions account
187+
git config user.email "github-actions[bot]@users.noreply.github.com"
188+
git config user.name "github-actions[bot]"
189+
# If this is a dev build and the last commit was from a dev build
190+
# (detect if "dev" was in the previous commit message), reuse the
191+
# same commit
192+
if [[ "${version}" == "dev" && `git log -1 --format='%s'` == *"dev"* ]]; then
193+
echo -e "\nAmending last commit:"
194+
git commit --amend --reset-author -m "$message"
195+
else
196+
echo -e "\nMaking a new commit:"
197+
git commit -m "$message"
198+
fi
199+
# Make the push quiet just in case there is anything that could leak
200+
# sensitive information.
201+
echo -e "\nPushing changes to gh-pages."
202+
git push -fq origin gh-pages 2>&1 >/dev/null
203+
echo -e "\nFinished uploading generated files."
204+
if: (github.event_name == 'release' || github.event_name == 'push') && (matrix.os == 'ubuntu-latest') && (matrix.python-version == '3.9')

.travis.yml

-77
This file was deleted.

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ Some things that will increase the chance that your pull request is accepted qui
435435
[numpy guide](https://numpydoc.readthedocs.io/en/latest/format.html)
436436
for documentation.
437437

438-
Pull requests will automatically have tests run by TravisCI.
438+
Pull requests will automatically have tests run by GitHub Actions.
439439
This includes running both the unit tests as well as code linters.
440440
GitHub will show the status of these checks on the pull request.
441441
Try to get them all passing (green).

MAINTENANCE.md

+10-21
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ If you want to make a contribution to the project, see the
1313
branch. Make a new branch and submit a pull request instead.
1414
* *gh-pages*: Holds the HTML documentation and is served by GitHub. Pages for the master
1515
branch are in the `dev` folder. Pages for each release are in their own folders.
16-
**Automatically updated by TravisCI** so you shouldn't have to make commits here.
16+
**Automatically updated by GitHub Actions** so you shouldn't have to make commits here.
1717

1818

1919
## Reviewing and merging pull requests
@@ -40,7 +40,7 @@ The main advantages of this are:
4040

4141
## Continuous Integration
4242

43-
We use GitHub Actions and TravisCI continuous integration (CI) services to
43+
We use GitHub Actions continuous integration (CI) services to
4444
build and test the project on Linux, macOS and Windows.
4545
They rely on the `requirements.txt` file to install required dependencies using
4646
conda and the `Makefile` to run the tests and checks.
@@ -54,6 +54,12 @@ There are 4 configuration files located in `.github/workflows`:
5454
This is ran on every commit on the *master* and Pull Request branches.
5555
It is also scheduled to run daily on the *master* branch.
5656

57+
On the *master* branch, the workflow also handles the documentation deployment:
58+
59+
* Updating the development documentation by pushing the built HTML pages from the
60+
*master* branch onto the `dev` folder of the *gh-pages* branch.
61+
* Updated the `latest` documentation link to the new release.
62+
5763
2. `ci_tests_dev.yaml` (GMT Latest Tests on Linux/macOS).
5864

5965
This is only triggered when a review is requested or re-requested on a PR.
@@ -72,23 +78,6 @@ Archives will be pushed to TestPyPI on every commit to the *master* branch and
7278
tagged releases, and to PyPI for tagged releases only.
7379

7480

75-
### Travis CI
76-
77-
The configuration file is at `.travis.yml`.
78-
Travis runs tests (Linux only) and handles the documentation deployment automatically:
79-
80-
* Updating the development documentation by pushing the built HTML pages from the
81-
*master* branch onto the `dev` folder of the *gh-pages* branch.
82-
* Updated the `latest` documentation link to the new release.
83-
84-
This way, most day-to-day maintenance operations are automatic.
85-
86-
The scripts that setup the test environment and run the deployments are loaded from the
87-
[fatiando/continuous-integration](https://github.com/fatiando/continuous-integration)
88-
repository to avoid duplicating work across multiple repositories.
89-
If you find any problems with the test setup and deployment, please create issues and
90-
submit pull requests to that repository.
91-
9281
## Continuous Documentation
9382

9483
We use the [Zeit Now for GitHub integration](https://zeit.co/github) to preview changes
@@ -102,7 +91,7 @@ see https://zeit.co/docs/v2/build-step/?query=package.json#defining-a-build-scri
10291
## Making a Release
10392

10493
We try to automate the release process as much as possible.
105-
Travis handles publishing new releases to PyPI and updating the documentation.
94+
GitHub Actions workflow handles publishing new releases to PyPI and updating the documentation.
10695
The version number is set automatically using setuptools_scm based information
10796
obtained from git.
10897
There are a few steps that still must be done manually, though.
@@ -166,7 +155,7 @@ and clicking on publish. A git tag will also be created, make sure that this
166155
tag is a proper version number (following [Semantic Versioning](https://semver.org/))
167156
with a leading `v`. E.g. `v0.2.1`.
168157
169-
Once the release/tag is created, this should trigger Travis to do all the work for us.
158+
Once the release/tag is created, this should trigger GitHub Actions to do all the work for us.
170159
A new source distribution will be uploaded to PyPI, a new folder with the documentation
171160
HTML will be pushed to *gh-pages*, and the `latest` link will be updated to point to
172161
this new folder.

README.rst

-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ PyGMT
1010
.. image:: http://img.shields.io/pypi/v/pygmt.svg?style=flat-square
1111
:alt: Latest version on PyPI
1212
:target: https://pypi.python.org/pypi/pygmt
13-
.. image:: http://img.shields.io/travis/GenericMappingTools/pygmt/master.svg?style=flat-square&label=Linux
14-
:alt: Travis CI build status
15-
:target: https://travis-ci.org/GenericMappingTools/pygmt
1613
.. image:: https://github.com/GenericMappingTools/pygmt/workflows/Tests/badge.svg
1714
:alt: GitHub Actions Tests status
1815
:target: https://github.com/GenericMappingTools/pygmt/actions?query=workflow%3ATests

0 commit comments

Comments
 (0)