-
Notifications
You must be signed in to change notification settings - Fork 76
126 lines (109 loc) · 3.74 KB
/
deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#
# Build and deploy the documentation
#
name: Deploy
on:
# pull_request: # enable pull_request for testing
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
deploy:
runs-on: ubuntu-latest
env:
GMT_DOC_VERSION: 6.5
defaults:
run:
shell: bash -l {0}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Micromamba
uses: mamba-org/[email protected]
with:
environment-file: environment.yml
cache-downloads: true
cache-environment: true
- name: Download remote data from GitHub
uses: dawidd6/action-download-artifact@v6
with:
workflow: cache-data.yml
workflow_conclusion: success
name: gmt-cache
path: .gmt
- name: Move and list downloaded remote files
run: |
# move the .gmt directory to the HOME directory
mv .gmt ~/
# Change modification times of the two files, so GMT won't refresh it
touch ~/.gmt/server/gmt_data_server.txt ~/.gmt/server/gmt_hash_server.txt
ls -lhR ~/.gmt
# Because building the PDF document is slow, the building and deployment
# process is designed as follows:
#
# 1. Build the HTML document and use the old PDF document and HTML zip if available
# 2. Deploy the HTML document
# 3. Build the HTML document again (html, not dirhtml) and make a zip
# 4. Build the PDF document
# 5. Deploy the PDF document and HTML zip
#
- name: Build HTML
run: make build_html
- name: Checkout the gh-pages branch
uses: actions/checkout@v4
with:
ref: gh-pages
path: deploy
fetch-depth: 0
- name: Prepare the documentation for deployment
run: |
cd deploy
# generate the .nojekyll file in the root directory
touch .nojekyll
# generate CNAME in the root directory
echo docs.gmt-china.org > CNAME
# Use the old PDF documentation because the new PDF documentation is not built
if [ -e ${GMT_DOC_VERSION}/GMT_docs.pdf ]; then
cp ${GMT_DOC_VERSION}/GMT_docs.pdf ../build/dirhtml/
fi
# Use the old HTML zip because the new HTML zip is not built
if [ -e ${GMT_DOC_VERSION}/GMT_docs.zip ]; then
cp ${GMT_DOC_VERSION}/GMT_docs.zip ../build/dirhtml/
fi
# Replace the old documentation with tht new one.
rm -rvf ${GMT_DOC_VERSION}
cp -rvf ../build/dirhtml/ ${GMT_DOC_VERSION}/
# let "latest" link to the latest version
rm -rfv latest
ln -sfv ${GMT_DOC_VERSION} latest
cd ..
- name: Deploy the HTML documentation to gh-pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
force_orphan: true
publish_dir: deploy
- name: Install TinyTeX
uses: r-lib/actions/setup-tinytex@v2
- name: Install LaTeX packages
run: bash scripts/setup-latex.sh
- name: Build the HMTL zip
run: |
make html
mv build/html GMT_docs
zip -r GMT_docs.zip GMT_docs
rm -r GMT_docs
mv GMT_docs.zip deploy/${GMT_DOC_VERSION}/
- name: Build PDF
run: |
make build_pdf
cp build/dirhtml/GMT_docs.pdf deploy/${GMT_DOC_VERSION}/
- name: Deploy the PDF documentation to gh-pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
force_orphan: true
publish_dir: deploy