Skip to content

Commit 0c7c217

Browse files
committed
🔄 Synced local '.github/workflows/' with remote '.github/workflows/'
release-
1 parent 5cc4172 commit 0c7c217

File tree

2 files changed

+91
-52
lines changed

2 files changed

+91
-52
lines changed

.github/workflows/pull_request.yml

+25-17
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Candace Savonen 2021
2-
# Updated Jan 2023
2+
# Updated May 2024
33

44
name: Pull Request
55

@@ -39,11 +39,12 @@ jobs:
3939
branch_name='preview-${{ github.event.pull_request.number }}'
4040
echo branch doesnt exist
4141
git checkout -b $branch_name || echo branch exists
42-
git push --set-upstream origin $branch_name || echo echo branch exists remotely
42+
git push --set-upstream origin $branch_name || echo branch exists remotely
4343
shell: bash
4444

4545

4646
outputs:
47+
toggle_website: "${{ env.RENDER_WEBSITE }}"
4748
toggle_spell_check: "${{ env.SPELL_CHECK }}"
4849
toggle_style_code: "${{ env.STYLE_CODE }}"
4950
toggle_url_check: "${{ env.URL_CHECKER }}"
@@ -101,13 +102,13 @@ jobs:
101102
fetch-depth: 0
102103

103104
- name: Run styler
104-
run: Rscript -e "styler::style_file(list.files(pattern = 'Rmd$', recursive = TRUE, full.names = TRUE));warnings()"
105+
run: Rscript -e "styler::style_file(list.files(pattern = '(R|q)md$', recursive = FALSE, full.names = TRUE));warnings()"
105106

106107
- name: Commit styled files
107108
run: |
108109
git config --system --add safe.directory "$GITHUB_WORKSPACE"
109-
git add \*.Rmd
110-
git commit -m 'Style Rmds' || echo "No changes to commit"
110+
git add \*md
111+
git commit -m 'Style *mds' || echo "No changes to commit"
111112
git push origin || echo "No changes to commit"
112113
113114
############################# Render Preview ###################################
@@ -142,23 +143,32 @@ jobs:
142143
# Run bookdown rendering
143144
- name: Run bookdown render
144145
id: bookdown
146+
if: ${{needs.yaml-check.outputs.toggle_website == 'rmd' }}
145147
run: Rscript -e "bookdown::render_book('index.Rmd', output_format = 'all')"
146148

147-
# Run TOC-less version
148-
# Rendered content for Leanpub and Coursera is very similar.
149-
# This job creates a shared scaffold for both.
150-
- name: Run TOC-less version of render
151-
id: tocless
152-
run: Rscript -e "ottrpal::render_without_toc()"
149+
# Run quarto rendering
150+
- name: Render quarto version
151+
id: quarto
152+
if: ${{needs.yaml-check.outputs.toggle_website == 'quarto' }}
153+
run: Rscript -e "quarto::quarto_render('.')"
153154

154155
# This checks on the steps before it and makes sure that they completed.
155156
# If the renders didn't complete we don't want to commit the file changes
156-
- name: Check on render steps
157-
if: steps.bookdown.outcome != 'success' || steps.tocless.outcome != 'success'
157+
- name: Check on Rmd render steps
158+
if: ${{needs.yaml-check.outputs.toggle_website == 'rmd' }}
158159
run: |
159160
echo Bookdown status ${{steps.bookdown.outcome}}
160-
echo Toc-less status ${{steps.tocless.outcome}}
161-
exit 1
161+
if [${{steps.bookdown.outcome}} != 'success']; then
162+
exit 1
163+
fi
164+
165+
- name: Check on quarto render steps
166+
if: ${{needs.yaml-check.outputs.toggle_website == 'quarto' }}
167+
run: |
168+
echo Quarto status ${{steps.quarto.outcome}}
169+
if [${{steps.quarto.outcome}} != 'success']; then
170+
exit 1
171+
fi
162172
163173
- name: Website preview for download
164174
run: zip website-preview.zip docs/* -r
@@ -189,12 +199,10 @@ jobs:
189199
run: |
190200
course_name=$(head -n 1 _bookdown.yml | cut -d'"' -f 2| tr " " "-")
191201
bookdown_link=$(echo "https://htmlpreview.github.io/?https://raw.githubusercontent.com/$GITHUB_REPOSITORY/preview-${{ github.event.pull_request.number }}/docs/index.html")
192-
tocless_link=$(echo "https://htmlpreview.github.io/?https://raw.githubusercontent.com/$GITHUB_REPOSITORY/preview-${{ github.event.pull_request.number }}/docs/no_toc/index.html")
193202
docx_link=$(echo "https://github.com/$GITHUB_REPOSITORY/raw/preview-${{ github.event.pull_request.number }}/docs/$course_name.docx")
194203
zip_link=$(echo "https://github.com/$GITHUB_REPOSITORY/raw/preview-${{ github.event.pull_request.number }}/website-preview.zip")
195204
echo "zip_link=$zip_link" >> $GITHUB_OUTPUT
196205
echo "bookdown_link=$bookdown_link" >> $GITHUB_OUTPUT
197-
echo "tocless_link=$tocless_link" >> $GITHUB_OUTPUT
198206
echo "docx_link=$docx_link" >> $GITHUB_OUTPUT
199207
echo "time=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
200208
echo "commit_id=$GITHUB_SHA" >> $GITHUB_OUTPUT

.github/workflows/render-all.yml

+66-35
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
2-
# Candace Savonen Apr 2021
1+
# Candace Savonen 2021
2+
# Updated May 2024
33

44
name: Render all output courses
55

@@ -8,7 +8,7 @@ on:
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

Comments
 (0)