Skip to content

Commit 57b0db0

Browse files
committed
🔄 Synced local '.github/workflows/' with remote '.github/workflows/'
release-
1 parent 27fb0e7 commit 57b0db0

File tree

5 files changed

+265
-96
lines changed

5 files changed

+265
-96
lines changed

.github/workflows/check-url.yml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
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+
- name: Find issues
83+
id: find-issue
84+
env:
85+
GH_PAT: ${{ secrets.GH_PAT }}
86+
run: |
87+
echo "$GITHUB_REPOSITORY"
88+
curl -o find_issue.R https://raw.githubusercontent.com/jhudsl/ottr-reports/main/scripts/find_issue.R
89+
issue_exists=$(Rscript --vanilla find_issue.R --repo $GITHUB_REPOSITORY --git_pat $GH_PAT)
90+
echo URL issue exists: $issue_exists
91+
echo "issue_existence=$issue_exists" >> $GITHUB_OUTPUT
92+
93+
- name: If too many URL errors, then make an issue
94+
if: ${{ steps.check-report.outputs.error_num >= 1 && steps.find-issue.outputs.issue_existence == 0}}
95+
uses: JasonEtco/create-an-issue@v2
96+
with:
97+
filename: .github/ISSUE_TEMPLATE/url-error.md
98+
env:
99+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
100+
FILE_URL: ${{ steps.check-report.outputs.error_url }}
101+
ERROR_NUM: ${{ steps.check-report.outputs.error_num }}
102+
103+
- name: If no URL errors than delete the branch we made
104+
if: ${{ steps.check-report.outputs.error_num < 1 }}
105+
run: |
106+
git config --system --add safe.directory "$GITHUB_WORKSPACE"
107+
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: 49 additions & 29 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,9 +14,10 @@ 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
20+
token: ${{ secrets.GH_PAT }}
2021

2122
# Use the yaml-env-action action.
2223
- name: Load environment from YAML
@@ -32,16 +33,18 @@ jobs:
3233
- name: Make the branch fresh
3334
run: |
3435
git config --global --add safe.directory $GITHUB_WORKSPACE
35-
git config --global user.email "[email protected]"
36-
git config --global user.name "jhudsl-robot"
36+
git config --global user.name 'github-actions[bot]'
37+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
3738
3839
branch_name='preview-${{ github.event.pull_request.number }}'
3940
echo branch doesnt exist
4041
git checkout -b $branch_name || echo branch exists
41-
git push --set-upstream origin $branch_name
42+
git push --set-upstream origin $branch_name || echo branch exists remotely
4243
shell: bash
4344

45+
4446
outputs:
47+
toggle_website: "${{ env.RENDER_WEBSITE }}"
4548
toggle_spell_check: "${{ env.SPELL_CHECK }}"
4649
toggle_style_code: "${{ env.STYLE_CODE }}"
4750
toggle_url_check: "${{ env.URL_CHECKER }}"
@@ -59,6 +62,7 @@ jobs:
5962
check_type: spelling
6063
error_min: 3
6164
gh_pat: secrets.GH_PAT
65+
branch_name: ${GITHUB_HEAD_REF}
6266

6367
url-check:
6468
name: Check URLs
@@ -69,6 +73,7 @@ jobs:
6973
check_type: urls
7074
error_min: 0
7175
gh_pat: secrets.GH_PAT
76+
branch_name: ${GITHUB_HEAD_REF}
7277

7378
quiz-check:
7479
name: Check quiz formatting
@@ -79,6 +84,7 @@ jobs:
7984
check_type: quiz_format
8085
error_min: 0
8186
gh_pat: secrets.GH_PAT
87+
branch_name: ${GITHUB_HEAD_REF}
8288

8389
############################# Style the code ###################################
8490
style-code:
@@ -91,18 +97,18 @@ jobs:
9197

9298
steps:
9399
- name: Checkout files
94-
uses: actions/checkout@v3
100+
uses: actions/checkout@v4
95101
with:
96102
fetch-depth: 0
97103

98104
- name: Run styler
99-
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()"
100106

101107
- name: Commit styled files
102108
run: |
103109
git config --system --add safe.directory "$GITHUB_WORKSPACE"
104-
git add \*.Rmd
105-
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"
106112
git push origin || echo "No changes to commit"
107113
108114
############################# Render Preview ###################################
@@ -117,16 +123,16 @@ jobs:
117123

118124
steps:
119125
- name: Checkout files
120-
uses: actions/checkout@v3
126+
uses: actions/checkout@v4
121127
with:
122128
fetch-depth: 0
123129

124130
# Set up git checkout
125131
- name: Set up git checkout
126132
run: |
127133
git config --global --add safe.directory $GITHUB_WORKSPACE
128-
git config --global user.email "[email protected]"
129-
git config --global user.name "jhudsl-robot"
134+
git config --global user.name 'github-actions[bot]'
135+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
130136
131137
branch_name='preview-${{ github.event.pull_request.number }}'
132138
git fetch --all
@@ -137,23 +143,35 @@ jobs:
137143
# Run bookdown rendering
138144
- name: Run bookdown render
139145
id: bookdown
146+
if: ${{needs.yaml-check.outputs.toggle_website == 'rmd' }}
140147
run: Rscript -e "bookdown::render_book('index.Rmd', output_format = 'all')"
141148

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

149155
# This checks on the steps before it and makes sure that they completed.
150156
# If the renders didn't complete we don't want to commit the file changes
151-
- name: Check on render steps
152-
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' }}
153159
run: |
154160
echo Bookdown status ${{steps.bookdown.outcome}}
155-
echo Toc-less status ${{steps.tocless.outcome}}
156-
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
172+
173+
- name: Website preview for download
174+
run: zip website-preview.zip docs/* -r
157175

158176
# Commit the rendered bookdown files
159177
- name: Commit rendered bookdown files to preview branch
@@ -164,7 +182,7 @@ jobs:
164182
echo "changes=$changes" >> $GITHUB_OUTPUT
165183
git add . --force
166184
git commit -m 'Render preview' || echo "No changes to commit"
167-
git pull --set-upstream origin $branch_name --allow-unrelated-histories --strategy-option=ours
185+
git pull --rebase --set-upstream origin $branch_name --allow-unrelated-histories --strategy-option=ours
168186
git push --force || echo "No changes to commit"
169187
shell: bash
170188

@@ -181,10 +199,10 @@ jobs:
181199
run: |
182200
course_name=$(head -n 1 _bookdown.yml | cut -d'"' -f 2| tr " " "-")
183201
bookdown_link=$(echo "https://htmlpreview.github.io/?https://raw.githubusercontent.com/$GITHUB_REPOSITORY/preview-${{ github.event.pull_request.number }}/docs/index.html")
184-
tocless_link=$(echo "https://htmlpreview.github.io/?https://raw.githubusercontent.com/$GITHUB_REPOSITORY/preview-${{ github.event.pull_request.number }}/docs/no_toc/index.html")
185202
docx_link=$(echo "https://github.com/$GITHUB_REPOSITORY/raw/preview-${{ github.event.pull_request.number }}/docs/$course_name.docx")
203+
zip_link=$(echo "https://github.com/$GITHUB_REPOSITORY/raw/preview-${{ github.event.pull_request.number }}/website-preview.zip")
204+
echo "zip_link=$zip_link" >> $GITHUB_OUTPUT
186205
echo "bookdown_link=$bookdown_link" >> $GITHUB_OUTPUT
187-
echo "tocless_link=$tocless_link" >> $GITHUB_OUTPUT
188206
echo "docx_link=$docx_link" >> $GITHUB_OUTPUT
189207
echo "time=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
190208
echo "commit_id=$GITHUB_SHA" >> $GITHUB_OUTPUT
@@ -198,11 +216,13 @@ jobs:
198216
issue-number: ${{ github.event.pull_request.number }}
199217
body: |
200218
Re-rendered previews from the latest commit:
201-
- See [preview of Bookdown here](${{ steps.build-components.outputs.bookdown_link }})
202-
- See [preview of Coursera/Leanpub version here](${{ steps.build-components.outputs.tocless_link }})
203-
- Download the [preview of .docx file](${{ steps.build-components.outputs.docx_link }})
219+
- :eyes: Quick [preview of course website here](${{ steps.build-components.outputs.bookdown_link }}) \*
220+
- :microscope: Comprehensive [download of the course website here](${{ steps.build-components.outputs.zip_link }})
221+
- Download the [.docx file](${{ steps.build-components.outputs.docx_link }})
204222
205-
_Updated at ${{ steps.build-components.outputs.time }} with changes from ${{ steps.build-components.outputs.commit_id }}_
223+
\* note not all html features will be properly displayed in the "quick preview" but it will give you a rough idea.
224+
225+
_Updated at ${{ steps.build-components.outputs.time }} with changes from the latest commit ${{ steps.build-components.outputs.commit_id }}_
206226
edit-mode: replace
207227

208228
- name: Comment if no changes

0 commit comments

Comments
 (0)