-
-
Notifications
You must be signed in to change notification settings - Fork 45
173 lines (140 loc) · 5.21 KB
/
docs-build.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# For more information about TARDIS pipelines, please refer to:
#
# https://tardis-sn.github.io/tardis/development/continuous_integration.html
name: docs
on:
push:
branches:
- '*'
workflow_dispatch:
schedule:
- cron: '0 0 * * 0' # run at midnight every Sunday
concurrency:
group: docs-${{ github.ref }}
cancel-in-progress: true
env:
XUVTOP: /tmp/chianti
CHIANTI_DL_URL: https://download.chiantidatabase.org
CHIANTI_DB_VER: CHIANTI_v9.0.1_database.tar.gz
CMFGEN_DL_URL: http://kookaburra.phyast.pitt.edu/hillier/cmfgen_files
CMFGEN_DB_VER: atomic_data_15nov16.tar.gz
jobs:
build:
# The `docs` workflow is triggered when a commit is pushed to any branch
# of the main repo or fork, but the `build` job starts when one of these
# conditions is met:
#
# a) the branch is `master`
# b) the branch name contains the word `doc(s)`
# c) the commit message includes the a valid tag
# d) the workflow has been triggered manually
if: github.ref == 'refs/heads/master' ||
github.event_name == 'workflow_dispatch' ||
contains(github.ref, 'doc') ||
contains(github.event.head_commit.message, '[build docs]') ||
contains(github.event.head_commit.message, '[build_docs]') ||
contains(github.event.head_commit.message, '[build doc]') ||
contains(github.event.head_commit.message, '[build_doc]')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/cache@v2
with:
path: ${{ env.XUVTOP }}
key: ${{ env.CHIANTI_DB_VER }}
id: chianti-cache
- name: Download Chianti database
run: |
mkdir -p ${{ env.XUVTOP }}
wget -q ${{ env.CHIANTI_DL_URL }}/${{ env.CHIANTI_DB_VER }} -O ${{ env.XUVTOP }}/chianti.tar.gz
tar -zxf ${{ env.XUVTOP }}/chianti.tar.gz -C ${{ env.XUVTOP }} --warning=none
if: steps.chianti-cache.outputs.cache-hit != 'true'
- uses: actions/cache@v2
with:
path: /tmp/atomic
key: ${{ env.CMFGEN_DB_VER }}
id: cmfgen-cache
- name: Download CMFGEN database
run: |
wget -q -U "Mozilla/4.0" ${{ env.CMFGEN_DL_URL }}/${{ env.CMFGEN_DB_VER }} -O /tmp/atomic.tar.gz
tar -zxf /tmp/atomic.tar.gz -C /tmp
if: steps.cmfgen-cache.outputs.cache-hit != 'true'
- name: Setup environment
uses: conda-incubator/setup-miniconda@v2
with:
miniforge-variant: Mambaforge
miniforge-version: latest
environment-file: carsus_env3.yml
activate-environment: carsus
use-mamba: true
- name: Install package
shell: bash -l {0}
run: pip install -e .
- name: Build documentation
shell: bash -l {0}
run: cd docs/; make html
- uses: actions/upload-artifact@v2
with:
name: html-dir
path: docs/_build/html
deploy:
needs: build
# The website is deployed to the root of the `gh-pages` branch of the main
# repository or fork, only after a commit is pushed to the `master` branch,
# and the result will be displayed at:
#
# tardis-sn.github.io/carsus (main repository)
# OR <username>.github.io/carsus (forks)
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v2
with:
name: html-dir
path: docs/_build/html
- name: Deploy main site
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
publish_dir: docs/_build/html
force_orphan: true
preview:
needs: build
# Branch preview is only available on forks, and requires at least one of
# these conditions to be met:
#
# a) the branch name contains the word `doc(s)`
# b) commit message includes the a valid tag
# c) the workflow is triggered manually
#
# Result will be displayed at:
#
# <username>.github.io/carsus/branch/<branch-name>
if: github.repository_owner != 'tardis-sn' &&
github.ref != 'refs/heads/master' && (
github.event_name == 'workflow_dispatch' ||
contains(github.ref, 'doc') ||
contains(github.event.head_commit.message, '[build docs]') ||
contains(github.event.head_commit.message, '[build_docs]') ||
contains(github.event.head_commit.message, '[build doc]') ||
contains(github.event.head_commit.message, '[build_doc]'))
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v2
with:
name: html-dir
path: docs/_build/html
- name: Get branch name
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: get_branch_name
- name: Deploy branch site
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
publish_dir: docs/_build/html
destination_dir: branch/${{ steps.get_branch_name.outputs.branch }}
force_orphan: false