1
-
2
- # Candace Savonen Apr 2021
1
+ # Candace Savonen 2021
2
+ # Updated May 2024
3
3
4
4
name : Render all output courses
5
5
8
8
push :
9
9
branches : [ main, staging ]
10
10
paths :
11
- - ' **.Rmd '
11
+ - ' **md$ '
12
12
- assets/*
13
13
- quizzes/*
14
14
@@ -27,20 +27,19 @@ jobs:
27
27
with :
28
28
files : config_automation.yml # Pass a space-separated list of configuration files. Rightmost files take precedence.
29
29
outputs :
30
- toggle_bookdown : " ${{ env.RENDER_BOOKDOWN }}"
30
+ toggle_website : " ${{ env.RENDER_WEBSITE }}"
31
31
toggle_coursera : " ${{ env.RENDER_COURSERA }}"
32
32
toggle_leanpub : " ${{ env.RENDER_LEANPUB }}"
33
33
make_book_txt : " ${{ env.MAKE_BOOK_TXT }}"
34
34
rendering_docker_image : " ${{ env.RENDERING_DOCKER_IMAGE }}"
35
35
toggle_quiz_check : " ${{ env.CHECK_QUIZZES }}"
36
36
37
- render-bookdown :
38
- name : Render bookdown
37
+ render-course :
38
+ name : Render course preview
39
39
needs : yaml-check
40
40
runs-on : ubuntu-latest
41
41
container :
42
42
image : ${{needs.yaml-check.outputs.rendering_docker_image}}
43
- if : ${{needs.yaml-check.outputs.toggle_bookdown == 'yes'}}
44
43
45
44
steps :
46
45
- name : checkout
@@ -57,38 +56,56 @@ jobs:
57
56
58
57
# We want a fresh run of the renders each time
59
58
- name : Delete old docs/*
60
- run : rm -rf docs/*
59
+ run : |
60
+ git remote set-url origin https://${GH_PAT}@github.com/${GITHUB_REPOSITORY}
61
+ git fetch origin
62
+ git pull --rebase --allow-unrelated-histories --strategy-option=ours
61
63
62
- # Run bookdown rendering
64
+ # Run Rmd rendering
63
65
- name : Run bookdown render
64
66
id : bookdown
67
+ if : ${{needs.yaml-check.outputs.toggle_website == 'rmd' }}
65
68
run : |
69
+ rm -rf docs/*
66
70
Rscript -e "bookdown::render_book('index.Rmd', output_format = 'all');
67
71
file.copy(from = 'assets', to = 'docs/assets', overwrite = TRUE)"
68
72
73
+ - name : Render quarto version
74
+ id : quarto
75
+ if : ${{needs.yaml-check.outputs.toggle_website == 'quarto' }}
76
+ run : Rscript -e "quarto::quarto_render('.')"
77
+
69
78
# This checks on the steps before it and makes sure that they completed.
70
79
# If the renders didn't complete we don't want to commit the file changes
71
- - name : Check on render step
72
- if : steps.bookdown.outcome != 'success'
80
+ - name : Check on Rmd render steps
81
+ if : ${{needs.yaml-check.outputs.toggle_website == 'rmd' }}
73
82
run : |
74
83
echo Bookdown status ${{steps.bookdown.outcome}}
75
- exit 1
84
+ if [${{steps.bookdown.outcome}} != 'success']; then
85
+ exit 1
86
+ fi
76
87
77
- # Commit the rendered bookdown files
78
- - name : Commit rendered bookdown files
88
+ - name : Check on quarto render steps
89
+ if : ${{needs.yaml-check.outputs.toggle_website == 'quarto' }}
90
+ run : |
91
+ echo Quarto status ${{steps.quarto.outcome}}
92
+ if [${{steps.quarto.outcome}} != 'success']; then
93
+ exit 1
94
+ fi
95
+
96
+ # Commit the rendered course files
97
+ - name : Commit rendered course files
79
98
env :
80
99
GH_PAT : ${{ secrets.GH_PAT }}
81
100
run : |
82
- git remote set-url origin https://${GH_PAT}@github.com/${GITHUB_REPOSITORY}
83
- git fetch origin
84
101
git add --force docs/*
85
- git commit -m 'Render bookdown ' || echo "No changes to commit"
86
- git pull --allow-unrelated-histories --strategy-option=ours
102
+ git commit -m 'Render course ' || echo "No changes to commit"
103
+ git status docs/*
87
104
git push -u origin main || echo "No changes to push"
88
105
89
106
render-tocless :
90
107
name : Render TOC-less version for Leanpub or Coursera
91
- needs : [yaml-check, render-bookdown ]
108
+ needs : [yaml-check, render-course ]
92
109
runs-on : ubuntu-latest
93
110
container :
94
111
image : ${{needs.yaml-check.outputs.rendering_docker_image}}
@@ -106,31 +123,40 @@ jobs:
106
123
git config --global --add safe.directory $GITHUB_WORKSPACE
107
124
git config --global user.name 'github-actions[bot]'
108
125
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
126
+ git remote set-url origin https://${GH_PAT}@github.com/${GITHUB_REPOSITORY}
127
+ git fetch origin
128
+ git pull --rebase --allow-unrelated-histories --strategy-option=ours
109
129
110
130
# Rendered content for Leanpub and Coursera is very similar.
111
131
# This job creates a shared scaffold for both.
112
- - name : Run TOC-less version of render
113
- id : tocless
132
+ - name : Run TOC-less version of render -- Rmd version
133
+ if : ${{needs.yaml-check.outputs.toggle_website == 'rmd' }}
134
+ id : tocless_rmd
114
135
run : Rscript -e "ottrpal::render_without_toc()"
115
136
137
+ - name : Run TOC-less version of render -- quarto version
138
+ id : tocless_quarto
139
+ if : ${{needs.yaml-check.outputs.toggle_website == 'quarto' }}
140
+ run : |
141
+ Rscript -e "quarto::quarto_render('.', metadata = list(sidebar = F, toc = F),
142
+ quarto_args = c('--output-dir', 'docs/no_toc/'))"
143
+
116
144
# Commit the TOC-less version files
117
145
- name : Commit tocless bookdown files
118
146
env :
119
147
GH_PAT : ${{ secrets.GH_PAT }}
120
148
run : |
121
- git remote set-url origin https://${GH_PAT}@github.com/${GITHUB_REPOSITORY}
122
- git fetch origin
123
149
git add --force docs/no_toc*
124
150
git commit -m 'Render toc-less' || echo "No changes to commit"
125
- git pull --set-upstream origin $branch_name --allow-unrelated-histories --strategy-option=ours
151
+ git status docs/no_toc*
126
152
git push -u origin main || echo "No changes to push"
127
153
128
154
render-leanpub :
129
155
name : Finish Leanpub prep
130
156
needs : [yaml-check, render-tocless]
131
157
runs-on : ubuntu-latest
132
158
container :
133
- image : jhudsl/ottrpal:main
159
+ image : jhudsl/ottrpal
134
160
if : ${{needs.yaml-check.outputs.toggle_leanpub == 'yes'}}
135
161
136
162
steps :
@@ -145,6 +171,10 @@ jobs:
145
171
git config --global --add safe.directory $GITHUB_WORKSPACE
146
172
git config --global user.name 'github-actions[bot]'
147
173
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
174
+ git remote set-url origin https://${GH_PAT}@github.com/${GITHUB_REPOSITORY}
175
+ git fetch origin
176
+ git pull --rebase --allow-unrelated-histories --strategy-option=ours
177
+ ls docs/no_toc
148
178
149
179
# Create screenshots
150
180
- name : Run the screenshot creation
@@ -165,20 +195,19 @@ jobs:
165
195
GH_PAT : ${{ secrets.GH_PAT }}
166
196
run : |
167
197
rm -rf manuscript/
168
- git remote set-url origin https://${GH_PAT}@github.com/${GITHUB_REPOSITORY}
169
- git fetch origin
170
198
git add .
171
199
git commit -m 'Delete manuscript folder' || echo "No changes to commit"
172
- git pull --set-upstream origin $branch_name --allow-unrelated-histories --strategy-option=ours
173
200
git push -u origin main || echo "No changes to push"
174
201
175
202
- name : Run ottrpal::bookdown_to_embed_leanpub
176
203
if : ${{ needs.yaml-check.outputs.toggle_quiz_check == 'no'}}
177
204
run : |
205
+ echo needs.yaml-check.outputs.toggle_make_book_txt == 'yes'
206
+ echo needs.yaml-check.outputs.toggle_make_book_txt
178
207
Rscript -e "ottrpal::bookdown_to_embed_leanpub(
179
208
render = FALSE, \
180
209
chapt_img_key = 'resources/chapt_screen_images/chapter_urls.tsv', \
181
- make_book_txt = as.logical('${{needs.yaml-check.outputs.make_book_txt}}'), \
210
+ make_book_txt = as.logical('${{needs.yaml-check.outputs.make_book_txt == 'yes' }}'), \
182
211
quiz_dir = NULL)"
183
212
184
213
- name : Run ottrpal::bookdown_to_embed_leanpub
@@ -187,7 +216,7 @@ jobs:
187
216
Rscript -e "ottrpal::bookdown_to_embed_leanpub(
188
217
render = FALSE, \
189
218
chapt_img_key = 'resources/chapt_screen_images/chapter_urls.tsv', \
190
- make_book_txt = as.logical('${{needs.yaml-check.outputs.make_book_txt}}'))"
219
+ make_book_txt = as.logical('${{needs.yaml-check.outputs.make_book_txt == 'yes' }}'))"
191
220
192
221
# Commit the rendered Leanpub files
193
222
- name : Commit rendered Leanpub files
@@ -199,7 +228,8 @@ jobs:
199
228
git add --force resources/*
200
229
git add --force docs/*
201
230
git commit -m 'Render Leanpub' || echo "No changes to commit"
202
- git pull --allow-unrelated-histories --strategy-option=ours
231
+ git status docs/*
232
+ git pull --rebase --allow-unrelated-histories --strategy-option=ours --autostash
203
233
git push --force --set-upstream origin main || echo "No changes to push"
204
234
205
235
render-coursera :
@@ -222,27 +252,28 @@ jobs:
222
252
git config --global --add safe.directory $GITHUB_WORKSPACE
223
253
git config --global user.name 'github-actions[bot]'
224
254
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
255
+ git remote set-url origin https://${GH_PAT}@github.com/${GITHUB_REPOSITORY}
256
+ git fetch origin
257
+ git pull --rebase --allow-unrelated-histories --strategy-option=ours
225
258
226
259
# Run Coursera version
227
260
- name : Convert Leanpub quizzes to Coursera
228
261
if : needs.yaml-check.outputs.toggle_leanpub == 'yes' && needs.yaml-check.outputs.toggle_quiz_check == 'yes'
229
262
id : coursera
230
263
run : Rscript -e "ottrpal::convert_coursera_quizzes()"
231
264
232
- # Commit the rendered bookdown files
265
+ # Commit the rendered files
233
266
# Only commit coursera quizzes if the directory is present
234
267
- name : Commit rendered Coursera files
235
268
env :
236
269
GH_PAT : ${{ secrets.GH_PAT }}
237
270
run : |
238
- git remote set-url origin https://${GH_PAT}@github.com/${GITHUB_REPOSITORY}
239
- git fetch origin
240
271
if [ -d 'coursera_quizzes' ]; then
241
272
git add --force coursera_quizzes/*
242
273
fi
243
274
git add --force manuscript/*
244
275
git add --force resources/*
245
276
git add --force docs/*
246
277
git commit -m 'Render Coursera quizzes' || echo "No changes to commit"
247
- git pull --rebase --allow-unrelated-histories --strategy-option=ours
278
+ git status
248
279
git push -u origin main || echo "No changes to push"
0 commit comments