11# Candace Savonen 2021
2- # Updated May 2024
2+ # Updated May 2025
33
44name : Pull Request
55
@@ -45,57 +45,51 @@ jobs:
4545 outputs :
4646 toggle_website : " ${{ env.RENDER_WEBSITE }}"
4747 toggle_spell_check : " ${{ env.SPELL_CHECK }}"
48+ spell_error_min : " ${{ env.SPELL_ERROR_MIN }}"
4849 toggle_style_code : " ${{ env.STYLE_CODE }}"
4950 toggle_url_check : " ${{ env.URL_CHECKER }}"
51+ url_error_min : " ${{ env.URL_ERROR_MIN }}"
5052 toggle_quiz_check : " ${{ env.CHECK_QUIZZES }}"
53+ quiz_error_min : " ${{ env.QUIZ_ERROR_MIN }}"
5154 toggle_md_linter : " ${{ env.MARKDOWN_LINTER }}"
5255 toggle_readability : " ${{ env.READABILITY_REPORT }}"
5356 toggle_render_preview : " ${{ env.RENDER_PREVIEW }}"
57+ toggle_dictionary_sort : " ${{ env.DICTIONARY_SORT }}"
5458 rendering_docker_image : " ${{ env.RENDERING_DOCKER_IMAGE }}"
5559
5660# ######################### Make the error reports ##############################
57- spell-check :
58- name : Check spelling
61+ ottr-reports :
62+ name : Run Reports
5963 needs : yaml-check
60- if : ${{needs.yaml-check.outputs.toggle_spell_check == 'yes'}}
61- uses : jhudsl/ottr-reports/.github/workflows/report-maker.yml@main
62- with :
63- check_type : spelling
64- error_min : 3
65- branch_name : ${GITHUB_HEAD_REF}
66- secrets :
67- gh_pat : ${{ secrets.GH_PAT }}
68-
69- url-check :
70- name : Check URLs
71- needs : yaml-check
72- if : ${{needs.yaml-check.outputs.toggle_url_check == 'yes'}}
73- uses : jhudsl/ottr-reports/.github/workflows/report-maker.yml@main
74- with :
75- check_type : urls
76- error_min : 0
77- branch_name : ${GITHUB_HEAD_REF}
78- secrets :
79- gh_pat : ${{ secrets.GH_PAT }}
64+ if : ${{needs.yaml-check.outputs.toggle_spell_check == 'true' || needs.yaml-check.outputs.toggle_url_check == 'true' || needs.yaml-check.outputs.toggle_quiz_check == 'true'}}
65+ runs-on : ubuntu-latest
66+ permissions :
67+ pull-requests : write
8068
81- quiz-check :
82- name : Check quiz formatting
83- if : ${{needs.yaml-check.outputs.toggle_quiz_check == 'yes'}}
84- needs : yaml-check
85- uses : jhudsl/ottr-reports/.github/workflows/report-maker.yml@main
86- with :
87- check_type : quiz_format
88- error_min : 0
89- branch_name : ${GITHUB_HEAD_REF}
90- secrets :
91- gh_pat : ${{ secrets.GH_PAT }}
69+ steps :
70+ - name : Checkout Actions Repository
71+ uses : actions/checkout@v4
72+ with :
73+ fetch-depth : 0
74+
75+ - name : Run Reports
76+ id : run-reports
77+ uses : ottrproject/ottr-reports@main
78+ with :
79+ check_spelling : ${{needs.yaml-check.outputs.toggle_spell_check}}
80+ spelling_error_min : ${{needs.yaml-check.outputs.spell_error_min}}
81+ check_urls : ${{needs.yaml-check.outputs.toggle_url_check}}
82+ url_error_min : ${{needs.yaml-check.outputs.url_error_min}}
83+ check_quiz_form : ${{needs.yaml-check.outputs.toggle_spell_check}}
84+ quiz_error_min : ${{needs.yaml-check.outputs.quiz_error_min}}
85+ sort_dictionary : ${{needs.yaml-check.outputs.toggle_dictionary_sort}}
9286
9387# ############################ Style the code ###################################
9488 style-code :
9589 name : Style code
9690 needs : yaml-check
9791 runs-on : ubuntu-latest
98- if : ${{needs.yaml-check.outputs.toggle_style_code == 'yes '}}
92+ if : ${{needs.yaml-check.outputs.toggle_style_code == 'true '}}
9993 container :
10094 image : jhudsl/base_ottr:main
10195
@@ -121,7 +115,7 @@ jobs:
121115 name : Readability report
122116 needs : yaml-check
123117 runs-on : ubuntu-latest
124- if : ${{needs.yaml-check.outputs.toggle_readability == 'yes '}}
118+ if : ${{needs.yaml-check.outputs.toggle_readability == 'true '}}
125119
126120 steps :
127121 - name : Checkout repo
@@ -136,127 +130,23 @@ jobs:
136130 glob : ' **/*.md'
137131
138132# ############################ Render Preview ###################################
139-
140133 render-preview :
141134 name : Render preview
142135 needs : yaml-check
143136 runs-on : ubuntu-latest
144- container :
145- image : ${{needs.yaml-check.outputs.rendering_docker_image}}
146- if : ${{needs.yaml-check.outputs.toggle_render_preview == 'yes'}}
137+ if : ${{needs.yaml-check.outputs.toggle_render_preview == 'true'}}
138+ permissions :
139+ pull-requests : write
140+ contents : write
147141
148142 steps :
149- - name : Checkout files
150- uses : actions/checkout@v4
151- with :
152- fetch-depth : 0
153-
154- # Set up git checkout
155- - name : Set up git checkout
156- run : |
157- git config --global --add safe.directory $GITHUB_WORKSPACE
158- git config --global user.name 'github-actions[bot]'
159- git config --global user.email 'github-actions[bot]@users.noreply.github.com'
160-
161- branch_name='preview-${{ github.event.pull_request.number }}'
162- git fetch --all
163- git checkout $branch_name
164- git merge -s recursive --strategy-option=theirs origin/${{ github.head_ref }} --allow-unrelated-histories
165- shell : bash
166-
167- # Run bookdown rendering
168- - name : Run bookdown render
169- id : bookdown
170- if : ${{needs.yaml-check.outputs.toggle_website == 'rmd' }}
171- run : Rscript -e "bookdown::render_book('index.Rmd', output_format = 'all')"
172-
173- # Run quarto rendering
174- - name : Render quarto version
175- id : quarto
176- if : ${{needs.yaml-check.outputs.toggle_website == 'quarto' }}
177- run : Rscript -e "quarto::quarto_render('.')"
178-
179- # This checks on the steps before it and makes sure that they completed.
180- # If the renders didn't complete we don't want to commit the file changes
181- - name : Check on Rmd render steps
182- if : ${{needs.yaml-check.outputs.toggle_website == 'rmd' }}
183- run : |
184- echo Bookdown status ${{steps.bookdown.outcome}}
185- if [${{steps.bookdown.outcome}} != 'success']; then
186- exit 1
187- fi
188-
189- - name : Check on quarto render steps
190- if : ${{needs.yaml-check.outputs.toggle_website == 'quarto' }}
191- run : |
192- echo Quarto status ${{steps.quarto.outcome}}
193- if [${{steps.quarto.outcome}} != 'success']; then
194- exit 1
195- fi
196-
197- - name : Website preview for download
198- run : zip website-preview.zip docs/* -r
199-
200- # Commit the rendered bookdown files
201- - name : Commit rendered bookdown files to preview branch
202- id : commit
203- run : |
204- branch_name='preview-${{ github.event.pull_request.number }}'
205- git diff origin/main -- docs >/dev/null && changes=true || changes=false
206- echo "changes=$changes" >> $GITHUB_OUTPUT
207- git add . --force
208- git commit -m 'Render preview' || echo "No changes to commit"
209- git pull --rebase --set-upstream origin $branch_name --allow-unrelated-histories --strategy-option=ours
210- git push --force || echo "No changes to commit"
211- shell : bash
212-
213- - name : Find Comment
214- uses : peter-evans/find-comment@v2
215- id : fc
216- with :
217- issue-number : ${{ github.event.pull_request.number }}
218- comment-author : ' github-actions[bot]'
219- body-includes : latest commit
220-
221- - name : Build components of the comment
222- id : build-components
223- run : |
224- course_name=$(head -n 1 _bookdown.yml | cut -d'"' -f 2| tr " " "-")
225- bookdown_link=$(echo "https://htmlpreview.github.io/?https://raw.githubusercontent.com/$GITHUB_REPOSITORY/preview-${{ github.event.pull_request.number }}/docs/index.html")
226- docx_link=$(echo "https://github.com/$GITHUB_REPOSITORY/raw/preview-${{ github.event.pull_request.number }}/docs/$course_name.docx")
227- zip_link=$(echo "https://github.com/$GITHUB_REPOSITORY/raw/preview-${{ github.event.pull_request.number }}/website-preview.zip")
228- echo "zip_link=$zip_link" >> $GITHUB_OUTPUT
229- echo "bookdown_link=$bookdown_link" >> $GITHUB_OUTPUT
230- echo "docx_link=$docx_link" >> $GITHUB_OUTPUT
231- echo "time=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
232- echo "commit_id=$GITHUB_SHA" >> $GITHUB_OUTPUT
233- echo ${{steps.commit.outputs.changes}}
234-
235- - name : Create or update comment
236- if : steps.commit.outputs.changes == 'true'
237- uses : peter-evans/create-or-update-comment@v2
238- with :
239- comment-id : ${{ steps.fc.outputs.comment-id }}
240- issue-number : ${{ github.event.pull_request.number }}
241- body : |
242- Re-rendered previews from the latest commit:
243- - :eyes: Quick [preview of course website here](${{ steps.build-components.outputs.bookdown_link }}) \*
244- - :microscope: Comprehensive [download of the course website here](${{ steps.build-components.outputs.zip_link }})
245- - Download the [.docx file](${{ steps.build-components.outputs.docx_link }})
246-
247- \* note not all html features will be properly displayed in the "quick preview" but it will give you a rough idea.
248-
249- _Updated at ${{ steps.build-components.outputs.time }} with changes from the latest commit ${{ steps.build-components.outputs.commit_id }}_
250- edit-mode : replace
251-
252- - name : Comment if no changes
253- if : steps.commit.outputs.changes == 'false'
254- uses : peter-evans/create-or-update-comment@v2
255- with :
256- comment-id : ${{ steps.fc.outputs.comment-id }}
257- issue-number : ${{ github.event.pull_request.number }}
258- body : |
259- The latest commit did not produce rendering changes.
260-
261- _Updated at ${{ steps.build-components.outputs.time }} with changes from ${{ steps.build-components.outputs.commit_id }}_
262- edit-mode : replace
143+ - name : Checkout repo
144+ uses : actions/checkout@v4
145+ with :
146+ fetch-depth : 0
147+
148+ - name : Run render
149+ uses : ottrproject/ottr-preview@main
150+ with :
151+ toggle_website : ${{needs.yaml-check.outputs.toggle_website}}
152+ docker_image : ${{needs.yaml-check.outputs.rendering_docker_image}}
0 commit comments