1-
2- # Candace Savonen Apr 2021
1+ # Candace Savonen 2021
2+ # Updated May 2024
33
44name : Render all output courses
55
88 push :
99 branches : [ main, staging ]
1010 paths :
11- - ' **.Rmd '
11+ - ' **md$ '
1212 - assets/*
1313 - quizzes/*
1414
@@ -27,20 +27,19 @@ jobs:
2727 with :
2828 files : config_automation.yml # Pass a space-separated list of configuration files. Rightmost files take precedence.
2929 outputs :
30- toggle_bookdown : " ${{ env.RENDER_BOOKDOWN }}"
30+ toggle_website : " ${{ env.RENDER_WEBSITE }}"
3131 toggle_coursera : " ${{ env.RENDER_COURSERA }}"
3232 toggle_leanpub : " ${{ env.RENDER_LEANPUB }}"
3333 make_book_txt : " ${{ env.MAKE_BOOK_TXT }}"
3434 rendering_docker_image : " ${{ env.RENDERING_DOCKER_IMAGE }}"
3535 toggle_quiz_check : " ${{ env.CHECK_QUIZZES }}"
3636
37- render-bookdown :
38- name : Render bookdown
37+ render-course :
38+ name : Render course preview
3939 needs : yaml-check
4040 runs-on : ubuntu-latest
4141 container :
4242 image : ${{needs.yaml-check.outputs.rendering_docker_image}}
43- if : ${{needs.yaml-check.outputs.toggle_bookdown == 'yes'}}
4443
4544 steps :
4645 - name : checkout
@@ -57,38 +56,56 @@ jobs:
5756
5857 # We want a fresh run of the renders each time
5958 - 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
6163
62- # Run bookdown rendering
64+ # Run Rmd rendering
6365 - name : Run bookdown render
6466 id : bookdown
67+ if : ${{needs.yaml-check.outputs.toggle_website == 'rmd' }}
6568 run : |
69+ rm -rf docs/*
6670 Rscript -e "bookdown::render_book('index.Rmd', output_format = 'all');
6771 file.copy(from = 'assets', to = 'docs/assets', overwrite = TRUE)"
6872
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+
6978 # This checks on the steps before it and makes sure that they completed.
7079 # 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' }}
7382 run : |
7483 echo Bookdown status ${{steps.bookdown.outcome}}
75- exit 1
84+ if [${{steps.bookdown.outcome}} != 'success']; then
85+ exit 1
86+ fi
7687
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
7998 env :
8099 GH_PAT : ${{ secrets.GH_PAT }}
81100 run : |
82- git remote set-url origin https://${GH_PAT}@github.com/${GITHUB_REPOSITORY}
83- git fetch origin
84101 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/*
87104 git push -u origin main || echo "No changes to push"
88105
89106 render-tocless :
90107 name : Render TOC-less version for Leanpub or Coursera
91- needs : [yaml-check, render-bookdown ]
108+ needs : [yaml-check, render-course ]
92109 runs-on : ubuntu-latest
93110 container :
94111 image : ${{needs.yaml-check.outputs.rendering_docker_image}}
@@ -106,31 +123,40 @@ jobs:
106123 git config --global --add safe.directory $GITHUB_WORKSPACE
107124 git config --global user.name 'github-actions[bot]'
108125 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
109129
110130 # Rendered content for Leanpub and Coursera is very similar.
111131 # 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
114135 run : Rscript -e "ottrpal::render_without_toc()"
115136
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+
116144 # Commit the TOC-less version files
117145 - name : Commit tocless bookdown files
118146 env :
119147 GH_PAT : ${{ secrets.GH_PAT }}
120148 run : |
121- git remote set-url origin https://${GH_PAT}@github.com/${GITHUB_REPOSITORY}
122- git fetch origin
123149 git add --force docs/no_toc*
124150 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*
126152 git push -u origin main || echo "No changes to push"
127153
128154 render-leanpub :
129155 name : Finish Leanpub prep
130156 needs : [yaml-check, render-tocless]
131157 runs-on : ubuntu-latest
132158 container :
133- image : jhudsl/ottrpal:main
159+ image : jhudsl/ottrpal
134160 if : ${{needs.yaml-check.outputs.toggle_leanpub == 'yes'}}
135161
136162 steps :
@@ -145,6 +171,10 @@ jobs:
145171 git config --global --add safe.directory $GITHUB_WORKSPACE
146172 git config --global user.name 'github-actions[bot]'
147173 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
148178
149179 # Create screenshots
150180 - name : Run the screenshot creation
@@ -165,20 +195,19 @@ jobs:
165195 GH_PAT : ${{ secrets.GH_PAT }}
166196 run : |
167197 rm -rf manuscript/
168- git remote set-url origin https://${GH_PAT}@github.com/${GITHUB_REPOSITORY}
169- git fetch origin
170198 git add .
171199 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
173200 git push -u origin main || echo "No changes to push"
174201
175202 - name : Run ottrpal::bookdown_to_embed_leanpub
176203 if : ${{ needs.yaml-check.outputs.toggle_quiz_check == 'no'}}
177204 run : |
205+ echo needs.yaml-check.outputs.toggle_make_book_txt == 'yes'
206+ echo needs.yaml-check.outputs.toggle_make_book_txt
178207 Rscript -e "ottrpal::bookdown_to_embed_leanpub(
179208 render = FALSE, \
180209 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' }}'), \
182211 quiz_dir = NULL)"
183212
184213 - name : Run ottrpal::bookdown_to_embed_leanpub
@@ -187,7 +216,7 @@ jobs:
187216 Rscript -e "ottrpal::bookdown_to_embed_leanpub(
188217 render = FALSE, \
189218 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' }}'))"
191220
192221 # Commit the rendered Leanpub files
193222 - name : Commit rendered Leanpub files
@@ -199,7 +228,8 @@ jobs:
199228 git add --force resources/*
200229 git add --force docs/*
201230 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
203233 git push --force --set-upstream origin main || echo "No changes to push"
204234
205235 render-coursera :
@@ -222,27 +252,28 @@ jobs:
222252 git config --global --add safe.directory $GITHUB_WORKSPACE
223253 git config --global user.name 'github-actions[bot]'
224254 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
225258
226259 # Run Coursera version
227260 - name : Convert Leanpub quizzes to Coursera
228261 if : needs.yaml-check.outputs.toggle_leanpub == 'yes' && needs.yaml-check.outputs.toggle_quiz_check == 'yes'
229262 id : coursera
230263 run : Rscript -e "ottrpal::convert_coursera_quizzes()"
231264
232- # Commit the rendered bookdown files
265+ # Commit the rendered files
233266 # Only commit coursera quizzes if the directory is present
234267 - name : Commit rendered Coursera files
235268 env :
236269 GH_PAT : ${{ secrets.GH_PAT }}
237270 run : |
238- git remote set-url origin https://${GH_PAT}@github.com/${GITHUB_REPOSITORY}
239- git fetch origin
240271 if [ -d 'coursera_quizzes' ]; then
241272 git add --force coursera_quizzes/*
242273 fi
243274 git add --force manuscript/*
244275 git add --force resources/*
245276 git add --force docs/*
246277 git commit -m 'Render Coursera quizzes' || echo "No changes to commit"
247- git pull --rebase --allow-unrelated-histories --strategy-option=ours
278+ git status
248279 git push -u origin main || echo "No changes to push"
0 commit comments