1
1
# Candace Savonen 2021
2
- # Updated Jan 2023
2
+ # Updated May 2024
3
3
4
4
name : Pull Request
5
5
17
17
uses : actions/checkout@v4
18
18
with :
19
19
fetch-depth : 0
20
- token : ${{ secrets.GH_PAT }}
21
20
22
21
# Use the yaml-env-action action.
23
22
- name : Load environment from YAML
@@ -39,15 +38,18 @@ jobs:
39
38
branch_name='preview-${{ github.event.pull_request.number }}'
40
39
echo branch doesnt exist
41
40
git checkout -b $branch_name || echo branch exists
42
- git push --set-upstream origin $branch_name || echo echo branch exists remotely
41
+ git push --set-upstream origin $branch_name || echo branch exists remotely
43
42
shell : bash
44
43
45
44
46
45
outputs :
46
+ toggle_website : " ${{ env.RENDER_WEBSITE }}"
47
47
toggle_spell_check : " ${{ env.SPELL_CHECK }}"
48
48
toggle_style_code : " ${{ env.STYLE_CODE }}"
49
49
toggle_url_check : " ${{ env.URL_CHECKER }}"
50
50
toggle_quiz_check : " ${{ env.CHECK_QUIZZES }}"
51
+ toggle_md_linter : " ${{ env.MARKDOWN_LINTER }}"
52
+ toggle_readability : " ${{ env.READABILITY_REPORT }}"
51
53
toggle_render_preview : " ${{ env.RENDER_PREVIEW }}"
52
54
rendering_docker_image : " ${{ env.RENDERING_DOCKER_IMAGE }}"
53
55
60
62
with :
61
63
check_type : spelling
62
64
error_min : 3
63
- gh_pat : secrets.GH_PAT
64
65
branch_name : ${GITHUB_HEAD_REF}
66
+ secrets :
67
+ gh_pat : ${{ secrets.GH_PAT }}
65
68
66
69
url-check :
67
70
name : Check URLs
71
74
with :
72
75
check_type : urls
73
76
error_min : 0
74
- gh_pat : secrets.GH_PAT
75
77
branch_name : ${GITHUB_HEAD_REF}
78
+ secrets :
79
+ gh_pat : ${{ secrets.GH_PAT }}
76
80
77
81
quiz-check :
78
82
name : Check quiz formatting
82
86
with :
83
87
check_type : quiz_format
84
88
error_min : 0
85
- gh_pat : secrets.GH_PAT
86
89
branch_name : ${GITHUB_HEAD_REF}
90
+ secrets :
91
+ gh_pat : ${{ secrets.GH_PAT }}
87
92
88
93
# ############################ Style the code ###################################
89
94
style-code :
@@ -101,15 +106,35 @@ jobs:
101
106
fetch-depth : 0
102
107
103
108
- name : Run styler
104
- run : Rscript -e "styler::style_file(list.files(pattern = 'Rmd $', recursive = TRUE , full.names = TRUE));warnings()"
109
+ run : Rscript -e "styler::style_file(list.files(pattern = '(R|q)md $', recursive = FALSE , full.names = TRUE));warnings()"
105
110
106
111
- name : Commit styled files
107
112
run : |
108
113
git config --system --add safe.directory "$GITHUB_WORKSPACE"
109
- git add \*.Rmd
110
- git commit -m 'Style Rmds ' || echo "No changes to commit"
114
+ git add \*md
115
+ git commit -m 'Style *mds ' || echo "No changes to commit"
111
116
git push origin || echo "No changes to commit"
112
117
118
+ # ############################ Readability Report ###################################
119
+
120
+ readability-report :
121
+ name : Readability report
122
+ needs : yaml-check
123
+ runs-on : ubuntu-latest
124
+ if : ${{needs.yaml-check.outputs.toggle_readability == 'yes'}}
125
+
126
+ steps :
127
+ - name : Checkout repo
128
+ uses : actions/checkout@v4
129
+ with :
130
+ fetch-depth : 0
131
+
132
+ - name : Readability report
133
+ uses : Rebilly/lexi@v2
134
+ with :
135
+ github-token : ${{ secrets.GH_PAT }}
136
+ glob : ' **/*.md'
137
+
113
138
# ############################ Render Preview ###################################
114
139
115
140
render-preview :
@@ -142,23 +167,32 @@ jobs:
142
167
# Run bookdown rendering
143
168
- name : Run bookdown render
144
169
id : bookdown
170
+ if : ${{needs.yaml-check.outputs.toggle_website == 'rmd' }}
145
171
run : Rscript -e "bookdown::render_book('index.Rmd', output_format = 'all')"
146
172
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()"
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('.')"
153
178
154
179
# This checks on the steps before it and makes sure that they completed.
155
180
# 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'
181
+ - name : Check on Rmd render steps
182
+ if : ${{needs.yaml-check.outputs.toggle_website == 'rmd' }}
158
183
run : |
159
184
echo Bookdown status ${{steps.bookdown.outcome}}
160
- echo Toc-less status ${{steps.tocless.outcome}}
161
- exit 1
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
162
196
163
197
- name : Website preview for download
164
198
run : zip website-preview.zip docs/* -r
@@ -172,7 +206,7 @@ jobs:
172
206
echo "changes=$changes" >> $GITHUB_OUTPUT
173
207
git add . --force
174
208
git commit -m 'Render preview' || echo "No changes to commit"
175
- git pull --set-upstream origin $branch_name --allow-unrelated-histories --strategy-option=ours
209
+ git pull --rebase -- set-upstream origin $branch_name --allow-unrelated-histories --strategy-option=ours
176
210
git push --force || echo "No changes to commit"
177
211
shell : bash
178
212
@@ -189,12 +223,10 @@ jobs:
189
223
run : |
190
224
course_name=$(head -n 1 _bookdown.yml | cut -d'"' -f 2| tr " " "-")
191
225
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")
193
226
docx_link=$(echo "https://github.com/$GITHUB_REPOSITORY/raw/preview-${{ github.event.pull_request.number }}/docs/$course_name.docx")
194
227
zip_link=$(echo "https://github.com/$GITHUB_REPOSITORY/raw/preview-${{ github.event.pull_request.number }}/website-preview.zip")
195
228
echo "zip_link=$zip_link" >> $GITHUB_OUTPUT
196
229
echo "bookdown_link=$bookdown_link" >> $GITHUB_OUTPUT
197
- echo "tocless_link=$tocless_link" >> $GITHUB_OUTPUT
198
230
echo "docx_link=$docx_link" >> $GITHUB_OUTPUT
199
231
echo "time=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
200
232
echo "commit_id=$GITHUB_SHA" >> $GITHUB_OUTPUT
0 commit comments