|
| 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 | + |
| 32 | + with: |
| 33 | + access_token: ${{ github.token }} |
| 34 | + |
| 35 | + - name: Checkout |
| 36 | + |
| 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 | + |
| 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 | + |
| 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 |
0 commit comments