-
Notifications
You must be signed in to change notification settings - Fork 18
217 lines (210 loc) · 7.22 KB
/
docs.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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
name: Documentation
on: # Run action after unit test workflow is complete
workflow_run:
workflows: ['Ubuntu20 Py3.8']
types: [completed]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# ===========================
#
# Site
#
# ===========================
site:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
# Only run if unit tests have been passed
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Set up Git repository
uses: actions/checkout@v3
with:
fetch-depth: 0
# Get host preference from config.env file ===================
- name: Load config variables into env
run: |
grep -v '^#' config.env | tr -d "[:blank:]" >> $GITHUB_ENV
- name: Report host(s)
run: |
if ! [ -z "${branch}" ]; then
# If a host branch has been provided
echo "Host: ${{ github.event.repository.name }}.$branch"
#echo ::set-output name=branch::$branch
echo "{branch}={$branch}" >> $GITHUB_OUTPUT
fi
if ! [ -z "${dest_gh_repository+x}" ]; then
# If a host repository has been provided
echo "Host: $dest_gh_repository.$dest_branch"
#echo ::set-output name=dest_gh_username::$dest_gh_username
#echo ::set-output name=dest_gh_reponame::$dest_gh_repository
#echo ::set-output name=dest_gh_repobranch::$dest_branch
#echo ::set-output name=user_email::$user_email
echo "{dest_gh_username}={$dest_gh_username}" >> $GITHUB_OUTPUT
echo "{dest_gh_reponame}={$dest_gh_repository}" >> $GITHUB_OUTPUT
echo "{dest_gh_repobranch}={$dest_branch}" >> $GITHUB_OUTPUT
echo "{user_email}={$user_email}" >> $GITHUB_OUTPUT
fi
id: config
# Generate documentation =====================================
- name: Set up Python 3.7
uses: actions/setup-python@v4
with:
python-version: 3.7
- name: Install dependencies
run: |
python -m pip install --upgrade pip
make install
#pip install -r $codedir/requirements.txt
#pip install -r $docsdir/source/requirements.txt
- name: Install HTML math dependencies
run: |
sudo apt-get install dvipng
sudo apt-get install texlive-latex-extra
- name: Generate
run: |
#cd $docsdir
#make html
#echo ::set-output name=html::$docsdir/build/html
echo "{html}={$docsdir/build/_build/html}" >> $GITHUB_OUTPUT
make doc
id: generate
# REPO hosting ===============================================
# - name: Ready up
# if: env.dest_gh_repository != ''
# run: |
# cd $docsdir/build/_build/html
# touch .nojekyll
# - name: Push
# if: env.dest_gh_repository != ''
# uses: cpina/github-action-push-to-another-repository@main
# env:
# API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }}
# with:
# # Cannot use $ variable substitution in function inputs
# source-directory: ${{ steps.generate.outputs.html }}
# destination-github-username: ${{ steps.config.outputs.dest_gh_username }}
# destination-repository-name: ${{ steps.config.outputs.dest_gh_reponame }}
# target-branch: ${{ steps.config.outputs.dest_gh_repobranch }}
# user-email: ${{ steps.config.outputs.user_email }}
# commit-message: See ORIGIN_COMMIT from $GITHUB_REF
# BRANCH hosting =============================================
- name: Stow
if: env.branch != ''
run: |
cd ..
mkdir docs
mv -v ${{ github.event.repository.name }}/$docsdir/build/_build/html/* docs
- name: Switch
if: env.branch != ''
uses: actions/checkout@v3
with:
ref: docs #$branch #${{ steps.config.outputs.branch }}
- name: Clean
if: env.branch != ''
run: |
mkdir -p docs
cd docs
rm -rf *
- name: Ready up
if: env.branch != ''
run: |
mv -v ../docs/* docs
cd docs
touch .nojekyll
- name: Push
if: env.branch != ''
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git pull
git add -A && git commit --allow-empty -m "Updated Documentation"
git push -u origin docs #$branch #${{ steps.config.outputs.branch }}
# ===========================
#
# Reference
#
# ===========================
reference:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
# Only run if unit tests have been passed
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Set up Git repository
uses: actions/checkout@v3
with:
fetch-depth: 0
# Get host preference from config.env file ===================
- name: Load config variables into env
run: |
grep -v '^#' config.env | tr -d "[:blank:]" >> $GITHUB_ENV
# Generate LaTeX code ========================================
- name: Set up Python 3.7
uses: actions/setup-python@v4
with:
python-version: 3.7
- name: Install dependencies
run: |
#python -m pip install --upgrade pip
#pip install -r $codedir/requirements.txt
#pip install -r $docsdir/source/requirements.txt
make install
- name: Generate LaTeX code
run: |
cd $docsdir/src
make latex
#echo ::set-output name=latex::$docsdir/build/_build/latex
echo "{latex}={$docsdir/build/_build/latex}" >> $GITHUB_OUTPUT
id: generate
- name: Install LaTeX engine
run: |
sudo apt-get update
sudo apt-get install texlive
sudo apt-get install texlive-luatex
sudo apt-get install -y latexmk
- name: Install LaTeX dependencies
run: |
sudo apt-get install -y xindy
- name: Install LaTeX packages
run: |
sudo apt-get install texlive-latex-extra
sudo apt-get install texlive-fonts-extra
- name: Compile
run: |
cd $docsdir/build/_build/latex
make LATEXMKOPTS="-lualatex"
cd ../../../../
- name: Set
run: |
mkdir temp
mv -v $docsdir/build/_build/latex/torque-limitedsimplependulum.pdf temp/${{ github.event.repository.name }}.pdf
- name: Switch
if: env.branch != ''
run: |
cd docs
git checkout docs
cd ..
- name: Clean
if: env.branch != ''
run: |
mkdir -p $pdfdir
#cd $pdfdir
rm -rf $pdfdir/*
- name: Move
if: env.branch != ''
run: |
mv temp/${{ github.event.repository.name }}.pdf $pdfdir/${{ github.event.repository.name }}.pdf
- name: Push
if: env.branch != ''
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git pull
git add $pdfdir/${{ github.event.repository.name }}.pdf && git commit --allow-empty -m "Updated Report"
git push -u origin $branch #${{ github.event.repository.default_branch }}