Skip to content

Commit 9066624

Browse files
committed
🔄 Synced local '.github/workflows/' with remote '.github/workflows/'
release-2.1.0
1 parent 0ebcf2e commit 9066624

File tree

4 files changed

+307
-91
lines changed

4 files changed

+307
-91
lines changed

‎.github/workflows/check-url.yml

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: Periodic URL Check
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '0 0 1 * *'
7+
8+
jobs:
9+
set-up:
10+
name: Load user automation choices
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v3
15+
with:
16+
fetch-depth: 0
17+
18+
# Use the yaml-env-action action.
19+
- name: Load environment from YAML
20+
uses: doughepi/[email protected]
21+
with:
22+
files: config_automation.yml # Pass a space-separated list of configuration files. Rightmost files take precedence.
23+
outputs:
24+
toggle_url_check_periodically: "${{ env.URL_CHECK_PERIODICALLY }}"
25+
26+
url-check:
27+
name: Check URLs
28+
needs: set-up
29+
if: ${{needs.set-up.outputs.toggle_url_check_periodically == 'yes'}}
30+
runs-on: ubuntu-latest
31+
container:
32+
image: jhudsl/base_ottr:main
33+
34+
steps:
35+
- name: Checkout
36+
uses: actions/checkout@v3
37+
with:
38+
fetch-depth: 0
39+
40+
# Delete the branch if this has been run before
41+
- name: Delete branch locally and remotely
42+
run: git push origin --delete preview-spell-error || echo "No branch to delete"
43+
44+
# Make the branch fresh
45+
- name: Make the branch fresh
46+
run: |
47+
git config --global --add safe.directory $GITHUB_WORKSPACE
48+
git config --global user.name 'github-actions[bot]'
49+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
50+
51+
echo branch doesnt exist
52+
git checkout -b preview-spell-error || echo branch exists
53+
git push --set-upstream origin preview-spell-error || echo echo branch exists remotely
54+
shell: bash
55+
56+
- name: Run the check
57+
uses: jhudsl/ottr-reports@main
58+
id: check_results
59+
continue-on-error: true
60+
with:
61+
check_type: urls
62+
error_min: 1
63+
64+
- name: Declare file path and time
65+
id: check-report
66+
run: |
67+
error_num=$(cat check_reports/url_checks.tsv | wc -l)
68+
error_num="$((error_num-1))"
69+
echo "error_num=$error_num" >> $GITHUB_OUTPUT
70+
echo "error_url=https://github.com/${GITHUB_REPOSITORY}/blob/preview-spell-error/check_reports/url_checks.tsv" >> $GITHUB_OUTPUT
71+
shell: bash
72+
73+
- name: Stop if failure
74+
if: steps.check_results.outcome == 'failure'
75+
run: exit 1
76+
77+
- name: Print out error variables
78+
run: |
79+
echo ${{ steps.check-report.outputs.error_url }}
80+
echo ${{ steps.check-report.outputs.error_num }}
81+
82+
# Commit file
83+
- name: Commit tocless bookdown files
84+
if: ${{ steps.check-report.outputs.error_num >= 1 }}
85+
env:
86+
GH_PAT: ${{ secrets.GH_PAT }}
87+
run: |
88+
git add --force check_reports/url_checks.tsv
89+
git commit -m 'Add spell check file' || echo "No changes to commit"
90+
git push --set-upstream origin preview-spell-error || echo echo branch exists remotely
91+
92+
- name: Find issues
93+
id: find-issue
94+
env:
95+
GH_PAT: ${{ secrets.GH_PAT }}
96+
run: |
97+
echo "$GITHUB_REPOSITORY"
98+
curl -o find_issue.R https://raw.githubusercontent.com/jhudsl/ottr-reports/main/scripts/find_issue.R
99+
issue_exists=$(Rscript --vanilla find_issue.R --repo $GITHUB_REPOSITORY --git_pat $GH_PAT)
100+
echo URL issue exists: $issue_exists
101+
echo "issue_existence=$issue_exists" >> $GITHUB_OUTPUT
102+
103+
- name: If too many URL errors, then make an issue
104+
if: ${{ steps.check-report.outputs.error_num >= 1 && steps.find-issue.outputs.issue_existence == 0}}
105+
uses: JasonEtco/create-an-issue@v2
106+
with:
107+
filename: .github/ISSUE_TEMPLATE/url-error.md
108+
env:
109+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
110+
FILE_URL: ${{ steps.check-report.outputs.error_url }}
111+
ERROR_NUM: ${{ steps.check-report.outputs.error_num }}
112+
113+
- name: If no URL errors than delete the branch we made
114+
if: ${{ steps.check-report.outputs.error_num < 1 }}
115+
run: |
116+
git config --system --add safe.directory "$GITHUB_WORKSPACE"
117+
git push origin --delete preview-spell-error || echo "No branch to delete"

‎.github/workflows/delete-preview.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818

1919
# Check out current repository
2020
- name: checkout
21-
uses: actions/checkout@v3
21+
uses: actions/checkout@v4
2222
with:
2323
fetch-depth: 0
2424

‎.github/workflows/pull_request.yml

Lines changed: 78 additions & 33 deletions
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

@@ -14,7 +14,7 @@ jobs:
1414
runs-on: ubuntu-latest
1515
steps:
1616
- name: Checkout
17-
uses: actions/checkout@v3
17+
uses: actions/checkout@v4
1818
with:
1919
fetch-depth: 0
2020

@@ -31,20 +31,25 @@ jobs:
3131
# Make the branch fresh
3232
- name: Make the branch fresh
3333
run: |
34-
git config --local user.email "[email protected]"
35-
git config --local user.name "jhudsl-robot"
34+
git config --global --add safe.directory $GITHUB_WORKSPACE
35+
git config --global user.name 'github-actions[bot]'
36+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
3637
3738
branch_name='preview-${{ github.event.pull_request.number }}'
3839
echo branch doesnt exist
3940
git checkout -b $branch_name || echo branch exists
40-
git push --set-upstream origin $branch_name
41+
git push --set-upstream origin $branch_name || echo branch exists remotely
4142
shell: bash
4243

44+
4345
outputs:
46+
toggle_website: "${{ env.RENDER_WEBSITE }}"
4447
toggle_spell_check: "${{ env.SPELL_CHECK }}"
4548
toggle_style_code: "${{ env.STYLE_CODE }}"
4649
toggle_url_check: "${{ env.URL_CHECKER }}"
4750
toggle_quiz_check: "${{ env.CHECK_QUIZZES }}"
51+
toggle_md_linter: "${{ env.MARKDOWN_LINTER }}"
52+
toggle_readability: "${{ env.READABILITY_REPORT }}"
4853
toggle_render_preview: "${{ env.RENDER_PREVIEW }}"
4954
rendering_docker_image: "${{ env.RENDERING_DOCKER_IMAGE }}"
5055

@@ -57,7 +62,9 @@ jobs:
5762
with:
5863
check_type: spelling
5964
error_min: 3
60-
gh_pat: secrets.GH_PAT
65+
branch_name: ${GITHUB_HEAD_REF}
66+
secrets:
67+
gh_pat: ${{ secrets.GH_PAT }}
6168

6269
url-check:
6370
name: Check URLs
@@ -67,7 +74,9 @@ jobs:
6774
with:
6875
check_type: urls
6976
error_min: 0
70-
gh_pat: secrets.GH_PAT
77+
branch_name: ${GITHUB_HEAD_REF}
78+
secrets:
79+
gh_pat: ${{ secrets.GH_PAT }}
7180

7281
quiz-check:
7382
name: Check quiz formatting
@@ -77,7 +86,9 @@ jobs:
7786
with:
7887
check_type: quiz_format
7988
error_min: 0
80-
gh_pat: secrets.GH_PAT
89+
branch_name: ${GITHUB_HEAD_REF}
90+
secrets:
91+
gh_pat: ${{ secrets.GH_PAT }}
8192

8293
############################# Style the code ###################################
8394
style-code:
@@ -90,20 +101,40 @@ jobs:
90101

91102
steps:
92103
- name: Checkout files
93-
uses: actions/checkout@v3
104+
uses: actions/checkout@v4
94105
with:
95106
fetch-depth: 0
96107

97108
- name: Run styler
98-
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()"
99110

100111
- name: Commit styled files
101112
run: |
102113
git config --system --add safe.directory "$GITHUB_WORKSPACE"
103-
git add \*.Rmd
104-
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"
105116
git push origin || echo "No changes to commit"
106117
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+
107138
############################# Render Preview ###################################
108139

109140
render-preview:
@@ -116,16 +147,16 @@ jobs:
116147

117148
steps:
118149
- name: Checkout files
119-
uses: actions/checkout@v3
150+
uses: actions/checkout@v4
120151
with:
121152
fetch-depth: 0
122153

123154
# Set up git checkout
124155
- name: Set up git checkout
125156
run: |
126-
git config --system --add safe.directory "$GITHUB_WORKSPACE"
127-
git config --local user.email "[email protected]"
128-
git config --local user.name "jhudsl-robot"
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'
129160
130161
branch_name='preview-${{ github.event.pull_request.number }}'
131162
git fetch --all
@@ -136,23 +167,35 @@ jobs:
136167
# Run bookdown rendering
137168
- name: Run bookdown render
138169
id: bookdown
170+
if: ${{needs.yaml-check.outputs.toggle_website == 'rmd' }}
139171
run: Rscript -e "bookdown::render_book('index.Rmd', output_format = 'all')"
140172

141-
# Run TOC-less version
142-
# Rendered content for Leanpub and Coursera is very similar.
143-
# This job creates a shared scaffold for both.
144-
- name: Run TOC-less version of render
145-
id: tocless
146-
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('.')"
147178

148179
# This checks on the steps before it and makes sure that they completed.
149180
# If the renders didn't complete we don't want to commit the file changes
150-
- name: Check on render steps
151-
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' }}
152183
run: |
153184
echo Bookdown status ${{steps.bookdown.outcome}}
154-
echo Toc-less status ${{steps.tocless.outcome}}
155-
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
196+
197+
- name: Website preview for download
198+
run: zip website-preview.zip docs/* -r
156199

157200
# Commit the rendered bookdown files
158201
- name: Commit rendered bookdown files to preview branch
@@ -163,7 +206,7 @@ jobs:
163206
echo "changes=$changes" >> $GITHUB_OUTPUT
164207
git add . --force
165208
git commit -m 'Render preview' || echo "No changes to commit"
166-
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
167210
git push --force || echo "No changes to commit"
168211
shell: bash
169212

@@ -180,10 +223,10 @@ jobs:
180223
run: |
181224
course_name=$(head -n 1 _bookdown.yml | cut -d'"' -f 2| tr " " "-")
182225
bookdown_link=$(echo "https://htmlpreview.github.io/?https://raw.githubusercontent.com/$GITHUB_REPOSITORY/preview-${{ github.event.pull_request.number }}/docs/index.html")
183-
tocless_link=$(echo "https://htmlpreview.github.io/?https://raw.githubusercontent.com/$GITHUB_REPOSITORY/preview-${{ github.event.pull_request.number }}/docs/no_toc/index.html")
184226
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
185229
echo "bookdown_link=$bookdown_link" >> $GITHUB_OUTPUT
186-
echo "tocless_link=$tocless_link" >> $GITHUB_OUTPUT
187230
echo "docx_link=$docx_link" >> $GITHUB_OUTPUT
188231
echo "time=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
189232
echo "commit_id=$GITHUB_SHA" >> $GITHUB_OUTPUT
@@ -197,11 +240,13 @@ jobs:
197240
issue-number: ${{ github.event.pull_request.number }}
198241
body: |
199242
Re-rendered previews from the latest commit:
200-
- See [preview of Bookdown here](${{ steps.build-components.outputs.bookdown_link }})
201-
- See [preview of Coursera/Leanpub version here](${{ steps.build-components.outputs.tocless_link }})
202-
- Download the [preview of .docx file](${{ steps.build-components.outputs.docx_link }})
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 }})
203246
204-
_Updated at ${{ steps.build-components.outputs.time }} with changes from ${{ steps.build-components.outputs.commit_id }}_
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 }}_
205250
edit-mode: replace
206251

207252
- name: Comment if no changes

0 commit comments

Comments
 (0)