Skip to content

Commit a424890

Browse files
Merge pull request #117 from fhdsl/repo-sync/OTTR_Template/default
🔄 Synced file(s) with jhudsl/OTTR_Template
2 parents 9041c73 + 358cd4d commit a424890

File tree

11 files changed

+227
-64
lines changed

11 files changed

+227
-64
lines changed

.github/ISSUE_TEMPLATE/url-error.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
title: Broken URLs found in the course!
3+
labels: url-error
4+
---
5+
URL's in this course were just checked and some broken URLs were found.
6+
7+
**Number of errors:** {{ env.ERROR_NUM }}
8+
**File where errors are:** [url checks file here]({{ env.FILE_URL }})

.github/workflows/check-url.yml

+107
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

+1-1
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

+27-15
Original file line numberDiff line numberDiff line change
@@ -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
@@ -31,16 +32,17 @@ jobs:
3132
# Make the branch fresh
3233
- name: Make the branch fresh
3334
run: |
34-
git config --global --add safe.directory ${GITHUB_WORKSPACE}
35-
git config --global user.email "[email protected]"
36-
git config --global user.name "jhudsl-robot"
35+
git config --global --add safe.directory $GITHUB_WORKSPACE
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 echo branch exists remotely
4243
shell: bash
4344

45+
4446
outputs:
4547
toggle_spell_check: "${{ env.SPELL_CHECK }}"
4648
toggle_style_code: "${{ env.STYLE_CODE }}"
@@ -59,6 +61,7 @@ jobs:
5961
check_type: spelling
6062
error_min: 3
6163
gh_pat: secrets.GH_PAT
64+
branch_name: ${GITHUB_HEAD_REF}
6265

6366
url-check:
6467
name: Check URLs
@@ -69,6 +72,7 @@ jobs:
6972
check_type: urls
7073
error_min: 0
7174
gh_pat: secrets.GH_PAT
75+
branch_name: ${GITHUB_HEAD_REF}
7276

7377
quiz-check:
7478
name: Check quiz formatting
@@ -79,6 +83,7 @@ jobs:
7983
check_type: quiz_format
8084
error_min: 0
8185
gh_pat: secrets.GH_PAT
86+
branch_name: ${GITHUB_HEAD_REF}
8287

8388
############################# Style the code ###################################
8489
style-code:
@@ -91,7 +96,7 @@ jobs:
9196

9297
steps:
9398
- name: Checkout files
94-
uses: actions/checkout@v3
99+
uses: actions/checkout@v4
95100
with:
96101
fetch-depth: 0
97102

@@ -117,16 +122,16 @@ jobs:
117122

118123
steps:
119124
- name: Checkout files
120-
uses: actions/checkout@v3
125+
uses: actions/checkout@v4
121126
with:
122127
fetch-depth: 0
123128

124129
# Set up git checkout
125130
- name: Set up git checkout
126131
run: |
127-
git config --system --add safe.directory "$GITHUB_WORKSPACE"
128-
git config --local user.email "[email protected]"
129-
git config --local user.name "jhudsl-robot"
132+
git config --global --add safe.directory $GITHUB_WORKSPACE
133+
git config --global user.name 'github-actions[bot]'
134+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
130135
131136
branch_name='preview-${{ github.event.pull_request.number }}'
132137
git fetch --all
@@ -155,6 +160,9 @@ jobs:
155160
echo Toc-less status ${{steps.tocless.outcome}}
156161
exit 1
157162
163+
- name: Website preview for download
164+
run: zip website-preview.zip docs/* -r
165+
158166
# Commit the rendered bookdown files
159167
- name: Commit rendered bookdown files to preview branch
160168
id: commit
@@ -164,7 +172,7 @@ jobs:
164172
echo "changes=$changes" >> $GITHUB_OUTPUT
165173
git add . --force
166174
git commit -m 'Render preview' || echo "No changes to commit"
167-
git pull --set-upstream origin $branch_name --allow-unrelated-histories --strategy-option=ours
175+
git pull --rebase --set-upstream origin $branch_name --allow-unrelated-histories --strategy-option=ours
168176
git push --force || echo "No changes to commit"
169177
shell: bash
170178

@@ -183,6 +191,8 @@ jobs:
183191
bookdown_link=$(echo "https://htmlpreview.github.io/?https://raw.githubusercontent.com/$GITHUB_REPOSITORY/preview-${{ github.event.pull_request.number }}/docs/index.html")
184192
tocless_link=$(echo "https://htmlpreview.github.io/?https://raw.githubusercontent.com/$GITHUB_REPOSITORY/preview-${{ github.event.pull_request.number }}/docs/no_toc/index.html")
185193
docx_link=$(echo "https://github.com/$GITHUB_REPOSITORY/raw/preview-${{ github.event.pull_request.number }}/docs/$course_name.docx")
194+
zip_link=$(echo "https://github.com/$GITHUB_REPOSITORY/raw/preview-${{ github.event.pull_request.number }}/website-preview.zip")
195+
echo "zip_link=$zip_link" >> $GITHUB_OUTPUT
186196
echo "bookdown_link=$bookdown_link" >> $GITHUB_OUTPUT
187197
echo "tocless_link=$tocless_link" >> $GITHUB_OUTPUT
188198
echo "docx_link=$docx_link" >> $GITHUB_OUTPUT
@@ -198,11 +208,13 @@ jobs:
198208
issue-number: ${{ github.event.pull_request.number }}
199209
body: |
200210
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 }})
211+
- :eyes: Quick [preview of course website here](${{ steps.build-components.outputs.bookdown_link }}) \*
212+
- :microscope: Comprehensive [download of the course website here](${{ steps.build-components.outputs.zip_link }})
213+
- Download the [.docx file](${{ steps.build-components.outputs.docx_link }})
204214
205-
_Updated at ${{ steps.build-components.outputs.time }} with changes from ${{ steps.build-components.outputs.commit_id }}_
215+
\* note not all html features will be properly displayed in the "quick preview" but it will give you a rough idea.
216+
217+
_Updated at ${{ steps.build-components.outputs.time }} with changes from the latest commit ${{ steps.build-components.outputs.commit_id }}_
206218
edit-mode: replace
207219

208220
- name: Comment if no changes

0 commit comments

Comments
 (0)