-
Notifications
You must be signed in to change notification settings - Fork 76
116 lines (102 loc) · 4.28 KB
/
preview-pr.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
# Build and preview documentation in PRs.
# DOES NOT WORK FOR FORKS.
name: Preview PR
on:
pull_request:
jobs:
preview-pr:
runs-on: ubuntu-latest
env:
GMT_VERSION: 6.4.0
GMT_DOC_VERSION: 6.4
defaults:
run:
shell: bash -l {0}
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.11.0
- name: Checkout
uses: actions/checkout@v3
# Install Mambaforge with conda-forge dependencies
- name: Setup Mambaforge
uses: conda-incubator/setup-miniconda@v2.2.0
with:
python-version: 3.9
channels: conda-forge,nodefaults
channel-priority: strict
miniforge-version: latest
miniforge-variant: Mambaforge
mamba-version: "*"
use-mamba: true
- name: Install packages
run: |
mamba install -c conda-forge gmt=${GMT_VERSION}
pip install -r requirements.txt
# Install packages for GMT LaTeX integration
sudo apt update
sudo apt install texlive-latex-base texlive-binaries texlive-fonts-recommended
- name: Download remote data from GitHub
uses: dawidd6/action-download-artifact@v2.27.0
with:
workflow: cache-data.yml
workflow_conclusion: success
name: gmt-cache
path: .gmt
- name: Move and list downloaded remote files
run: |
mkdir -p ~/.gmt
mv .gmt/* ~/.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
# Chinese configuration
gmt text -L
cat ~/.gmt/cidfmap
cat ~/.gmt/PSL_custom_fonts.txt
cd $(gmt --show-sharedir)/localization
cp gmt_cn1.locale gmt_cn1.locale_old
iconv -f GBK -t UTF-8 gmt_cn1.locale_old > gmt_cn1.locale
- name: Build HTML
run: make build_html
- name: Deploy for preview
uses: peaceiris/actions-gh-pages@068dc23d9710f1ba62e86896f84735d869951305
with:
# personal token can be generated at https://github.com/settings/tokens,
# and added to https://github.com/organizations/gmt-china/settings/secrets/actions
personal_token: ${{ secrets.TOKEN_DOCUMENT_DEPLOY }}
publish_dir: ./build/dirhtml
destination_dir: ${{ github.repository }}/${{ github.head_ref }}
external_repository: gmt-china/sitepreview
keep_files: false
allow_empty_commit: true
force_orphan: false
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
if: github.event.pull_request.head.repo.full_name == github.repository
- name: Find Comment
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: This comment was written by the Continuous Documentation bot!
if: github.event.pull_request.head.repo.full_name == github.repository
- name: Create comment
uses: peter-evans/create-or-update-comment@v3
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
This comment was written by the Continuous Documentation bot!
- **Preview**: https://gmt-china.github.io/sitepreview/${{ github.repository }}/${{ github.head_ref }}/index.html
- **Commit hash**: ${{ github.event.pull_request.head.sha }}
if: github.event.pull_request.head.repo.full_name == github.repository && steps.fc.outputs.comment-id == 0
- name: Update comment
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
edit-mode: replace
body: |
This comment was written by the Continuous Documentation bot!
- **Preview**: https://gmt-china.github.io/sitepreview/${{ github.repository }}/${{ github.head_ref }}/index.html
- **Commit hash**: ${{ github.event.pull_request.head.sha }}
if: github.event.pull_request.head.repo.full_name == github.repository && steps.fc.outputs.comment-id != 0