-
Notifications
You must be signed in to change notification settings - Fork 0
249 lines (216 loc) · 9.05 KB
/
pull_request.yml
File metadata and controls
249 lines (216 loc) · 9.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
# Candace Savonen 2021
# Updated May 2025
name: Pull Request
on:
pull_request:
branches: [ main, staging ]
jobs:
yaml-check:
name: Load user automation choices
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
# Use the yaml-env-action action.
- name: Load environment from YAML
uses: doughepi/yaml-env-action@v1.0.0
with:
files: config_automation.yml # Pass a space-separated list of configuration files. Rightmost files take precedence.
# Delete the branch if this has been run before
- name: Delete branch locally and remotely
run: git push origin --delete preview-${{ github.event.pull_request.number }} || echo "No branch to delete"
# Make the branch fresh
- name: Make the branch fresh
run: |
git config --global --add safe.directory $GITHUB_WORKSPACE
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
branch_name='preview-${{ github.event.pull_request.number }}'
echo branch doesnt exist
git checkout -b $branch_name || echo branch exists
git push --set-upstream origin $branch_name || echo branch exists remotely
shell: bash
outputs:
toggle_website: "${{ env.RENDER_WEBSITE }}"
toggle_spell_check: "${{ env.SPELL_CHECK }}"
spell_error_min: "${{ env.SPELL_ERROR_MIN }}"
toggle_style_code: "${{ env.STYLE_CODE }}"
toggle_url_check: "${{ env.URL_CHECKER }}"
url_error_min: "${{ env.URL_ERROR_MIN }}"
toggle_quiz_check: "${{ env.CHECK_QUIZZES }}"
quiz_error_min: "${{ env.QUIZ_ERROR_MIN }}"
toggle_md_linter: "${{ env.MARKDOWN_LINTER }}"
toggle_readability: "${{ env.READABILITY_REPORT }}"
toggle_render_preview: "${{ env.RENDER_PREVIEW }}"
toggle_dictionary_sort: "${{ env.DICTIONARY_SORT }}"
rendering_docker_image: "${{ env.RENDERING_DOCKER_IMAGE }}"
toggle_feedback_link: "${{ env.FEEDBACK_LINK }}"
toggle_student_guide: "${{ env.RENDER_STUDENT_GUIDE }}"
########################## Make the error reports ##############################
ottr-reports:
name: Run Reports
needs: yaml-check
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'}}
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Checkout Actions Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Run Reports
id: run-reports
uses: ottrproject/ottr-reports@main
with:
check_spelling: ${{needs.yaml-check.outputs.toggle_spell_check}}
spelling_error_min: ${{needs.yaml-check.outputs.spell_error_min}}
check_urls: ${{needs.yaml-check.outputs.toggle_url_check}}
url_error_min: ${{needs.yaml-check.outputs.url_error_min}}
check_quiz_form: ${{needs.yaml-check.outputs.toggle_quiz_check}}
quiz_error_min: ${{needs.yaml-check.outputs.quiz_error_min}}
sort_dictionary: ${{needs.yaml-check.outputs.toggle_dictionary_sort}}
############################# Style the code ###################################
style-code:
name: Style code
needs: yaml-check
runs-on: ubuntu-latest
if: ${{needs.yaml-check.outputs.toggle_style_code == 'true'}}
container:
image: jhudsl/base_ottr:main
steps:
- name: Checkout files
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Run styler
run: Rscript -e "styler::style_file(list.files(pattern = '(R|q)md$', recursive = FALSE, full.names = TRUE));warnings()"
- name: Commit styled files
run: |
git config --system --add safe.directory "$GITHUB_WORKSPACE"
git add \*md
git commit -m 'Style *mds' || echo "No changes to commit"
git push origin || echo "No changes to commit"
############################# Readability Report ###################################
readability-report:
name: Readability report
needs: yaml-check
runs-on: ubuntu-latest
if: ${{needs.yaml-check.outputs.toggle_readability == 'true'}}
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Readability report
uses: Rebilly/lexi@v2
with:
github-token: ${{ secrets.GH_PAT }}
glob: '**/*.md'
############################# AnVIL Feedback Link ##############################
# Do not remove this section with OTTR syncs!
anvil-feedback:
name: Make AnVIL Feedback Link
needs: [yaml-check]
runs-on: ubuntu-latest
container:
image: ${{needs.yaml-check.outputs.rendering_docker_image}}
steps:
- name: Checkout files
uses: actions/checkout@v4
with:
fetch-depth: 0
# Set up git checkout
- name: Set up git checkout
run: |
git config --global --add safe.directory $GITHUB_WORKSPACE
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
branch_name='${{ github.head_ref }}'
git fetch --all
git checkout $branch_name
git merge -s recursive --strategy-option=theirs origin/${{ github.head_ref }} --allow-unrelated-histories
shell: bash
# Make sure the link for AnVIL feedback is prepopulated for the specific course
- name: Set up feedback link
id: feedback
if: ${{needs.yaml-check.outputs.toggle_feedback_link == 'true'}}
run: |
bash .github/AnVIL_Feedback_Script.sh
git add _output.yml
git commit -m 'Set up feedback link' || echo "No changes to commit"
git push origin || echo "No changes to commit"
############################# Render Preview ###################################
render-preview:
name: Render preview
needs: [yaml-check, anvil-feedback]
runs-on: ubuntu-latest
if: ${{needs.yaml-check.outputs.toggle_render_preview == 'true'}}
permissions:
pull-requests: write
contents: write
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Run render
uses: ottrproject/ottr-preview@main
with:
toggle_website: ${{needs.yaml-check.outputs.toggle_website}}
docker_image: ${{needs.yaml-check.outputs.rendering_docker_image}}
############################# Render Student Guide #############################
# Do not remove this section with OTTR syncs!
render-anvil-special:
name: Render AnVIL Special
needs: [yaml-check, render-preview]
runs-on: ubuntu-latest
if: ${{needs.yaml-check.outputs.toggle_render_preview == 'true'}}
container:
image: ${{needs.yaml-check.outputs.rendering_docker_image}}
steps:
- name: Checkout files
uses: actions/checkout@v4
with:
fetch-depth: 0
# Set up git checkout
- name: Set up git checkout
run: |
git config --global --add safe.directory $GITHUB_WORKSPACE
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
branch_name='preview-${{ github.event.pull_request.number }}'
git fetch --all
git checkout $branch_name
git merge -s recursive --strategy-option=theirs origin/${{ github.head_ref }} --allow-unrelated-histories
shell: bash
# Render a student guide if specified. This is a bit clunky because
# Bookdown does not work well if the files aren't named as such in the
# root directory
- name: Run student guide render
if: ${{needs.yaml-check.outputs.toggle_student_guide == 'true'}}
id: student_guide
run: |
mkdir tmp1
mv _bookdown.yml _output.yml tmp1
mv student-guide/_bookdown.yml student-guide/_output.yml .
Rscript -e "bookdown::render_book('index.Rmd', output_format = 'all')"
mv _bookdown.yml _output.yml student-guide
mv tmp1/_bookdown.yml tmp1/_output.yml .
rm -r tmp1
git add student-guide/*
git commit -m 'Create student guide' || echo "No changes to commit"
# Commit the rendered bookdown files
- name: Commit rendered bookdown files to preview branch
id: commit
run: |
branch_name='preview-${{ github.event.pull_request.number }}'
git diff origin/main -- docs >/dev/null && changes=true || changes=false
echo "changes=$changes" >> $GITHUB_OUTPUT
git add . --force
git commit -m 'Render AnVIL Special' || echo "No changes to commit"
git pull --rebase --set-upstream origin $branch_name --allow-unrelated-histories --strategy-option=ours
git push --force || echo "No changes to commit"
shell: bash