Skip to content

Commit 17133d1

Browse files
seismanweiji14
andauthored
Use Vercel action for continuous documentation (#964)
- Switch from the Vercel App to the Vercel action - Remove the old configuration files `package.json` and `vercel.json` - Update the maintenance guide Co-authored-by: Wei Ji <[email protected]>
1 parent a98fb85 commit 17133d1

File tree

4 files changed

+110
-22
lines changed

4 files changed

+110
-22
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# This workflow deploys documentation to Vercel for previewing PRs
2+
3+
name: Continuous Documentation
4+
5+
on:
6+
pull_request:
7+
paths:
8+
- 'doc/**'
9+
- 'examples/**'
10+
- 'pygmt/**'
11+
- 'README.rst'
12+
- '.github/workflows/continuous-documentation.yml'
13+
pull_request_target:
14+
paths:
15+
- 'doc/**'
16+
- 'examples/**'
17+
- 'pygmt/**'
18+
- 'README.rst'
19+
- '.github/workflows/continuous-documentation.yml'
20+
21+
jobs:
22+
vercel:
23+
name: Deploy to Vercel
24+
runs-on: ubuntu-latest
25+
defaults:
26+
run:
27+
shell: bash -l {0}
28+
29+
steps:
30+
- name: Cancel Previous Runs
31+
uses: styfle/[email protected]
32+
with:
33+
access_token: ${{ github.token }}
34+
35+
- name: Checkout
36+
uses: actions/[email protected]
37+
with:
38+
# fecth all history so that setuptools-scm works
39+
fetch-depth: 0
40+
41+
# Setup Miniconda
42+
- name: Setup Miniconda
43+
uses: conda-incubator/[email protected]
44+
with:
45+
activate-environment: pygmt
46+
python-version: 3.9
47+
channels: conda-forge
48+
miniconda-version: "latest"
49+
50+
- name: Install dependencies
51+
run: |
52+
conda install gmt=6.1.1 numpy pandas xarray netcdf4 packaging \
53+
ipython myst-parser sphinx sphinx-copybutton \
54+
sphinx-gallery sphinx_rtd_theme=0.4.3
55+
56+
- name: List installed packages
57+
run: conda list
58+
59+
- name: Download remote data from GitHub
60+
uses: dawidd6/[email protected]
61+
with:
62+
workflow: cache_data.yaml
63+
workflow_conclusion: success
64+
name: gmt-cache
65+
path: .gmt
66+
67+
- name: Move and list downloaded remote files
68+
run: |
69+
mkdir -p ~/.gmt
70+
mv .gmt/* ~/.gmt
71+
# Change modification times of the two files, so GMT won't refresh it
72+
touch ~/.gmt/server/gmt_data_server.txt ~/.gmt/server/gmt_hash_server.txt
73+
ls -lhR ~/.gmt
74+
75+
- name: Install the package
76+
run: |
77+
python setup.py sdist --formats=zip
78+
pip install dist/*
79+
80+
- name: Build the documentation
81+
run: make -C doc clean all
82+
83+
- name: Deploy documentation to Vercel
84+
uses: amondnet/[email protected]
85+
with:
86+
# Generate a vercel token at https://vercel.com/account/tokens,
87+
# and save the value in the secrets setting in the repository.
88+
vercel-token: ${{ secrets.VERCEL_TOKEN }}
89+
# https://github.com/marketplace/actions/vercel-action#project-linking
90+
# Install the Vercel CLI and run `vercel` in the project directory.
91+
# After linking the repository with a Vercel project, `vercel` will
92+
# create a `.vercel` directory containing both the organization (vercel-org-id)
93+
# and project (vercel-project-id) id of the project.
94+
# Save the values in the secrets setting in the repository.
95+
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
96+
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}
97+
github-token: ${{ secrets.GITHUB_TOKEN }}
98+
github-comment: true
99+
working-directory: ./doc/_build/html

MAINTENANCE.md

+11-8
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ conda and the `Makefile` to run the tests and checks.
4747

4848
### GitHub Actions
4949

50-
There are 5 configuration files located in `.github/workflows`:
50+
There are 6 configuration files located in `.github/workflows`:
5151

5252
1. `style_checks.yaml` (Code lint and style checks)
5353

@@ -84,16 +84,19 @@ This workflow is ran to publish wheels to PyPI and TestPyPI (for testing only).
8484
Archives will be pushed to TestPyPI on every commit to the *master* branch and
8585
tagged releases, and to PyPI for tagged releases only.
8686

87+
6. `continuous-documentation.yml` (Deploy documentation to Vercel for preview)
88+
89+
This workflow builds and deploys the documentation in Pull Requests to Vercel,
90+
to make it easier to preview documentation changes.
8791

8892
## Continuous Documentation
8993

90-
We use the [Vercel for GitHub](https://github.com/apps/vercel) App to preview changes
91-
made to our documentation website every time we make a commit in a pull request.
92-
The service has a configuration file `vercel.json`, with a list of options to
93-
change the default behaviour at https://vercel.com/docs/configuration.
94-
The actual script `package.json` is used by Vercel to install the necessary packages,
95-
build the documentation, copy the files to a 'public' folder and deploy that to the web,
96-
see https://vercel.com/docs/build-step.
94+
We use a cloud platform service called [Vercel](https://vercel.com/) via
95+
[vercel-action](https://github.com/marketplace/actions/vercel-action) to
96+
preview changes made to our documentation website every time we make a commit
97+
in a pull request. The workflow `continuous-documentation.yml` builds and
98+
deploys the documentation to Vercel. The vercel bot will automatically make a
99+
comment with a URL to preview the deployed documentation for that pull request.
97100

98101
## Making a Release
99102

package.json

-8
This file was deleted.

vercel.json

-6
This file was deleted.

0 commit comments

Comments
 (0)