Skip to content

Commit 9f3735a

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

File tree

5 files changed

+199
-53
lines changed

5 files changed

+199
-53
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: 26 additions & 13 deletions
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,15 +32,17 @@ jobs:
3132
# Make the branch fresh
3233
- name: Make the branch fresh
3334
run: |
34-
git config --local user.email "[email protected]"
35-
git config --local 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'
3638
3739
branch_name='preview-${{ github.event.pull_request.number }}'
3840
echo branch doesnt exist
3941
git checkout -b $branch_name || echo branch exists
40-
git push --set-upstream origin $branch_name
42+
git push --set-upstream origin $branch_name || echo echo branch exists remotely
4143
shell: bash
4244

45+
4346
outputs:
4447
toggle_spell_check: "${{ env.SPELL_CHECK }}"
4548
toggle_style_code: "${{ env.STYLE_CODE }}"
@@ -58,6 +61,7 @@ jobs:
5861
check_type: spelling
5962
error_min: 3
6063
gh_pat: secrets.GH_PAT
64+
branch_name: ${GITHUB_HEAD_REF}
6165

6266
url-check:
6367
name: Check URLs
@@ -68,6 +72,7 @@ jobs:
6872
check_type: urls
6973
error_min: 0
7074
gh_pat: secrets.GH_PAT
75+
branch_name: ${GITHUB_HEAD_REF}
7176

7277
quiz-check:
7378
name: Check quiz formatting
@@ -78,6 +83,7 @@ jobs:
7883
check_type: quiz_format
7984
error_min: 0
8085
gh_pat: secrets.GH_PAT
86+
branch_name: ${GITHUB_HEAD_REF}
8187

8288
############################# Style the code ###################################
8389
style-code:
@@ -90,7 +96,7 @@ jobs:
9096

9197
steps:
9298
- name: Checkout files
93-
uses: actions/checkout@v3
99+
uses: actions/checkout@v4
94100
with:
95101
fetch-depth: 0
96102

@@ -116,16 +122,16 @@ jobs:
116122

117123
steps:
118124
- name: Checkout files
119-
uses: actions/checkout@v3
125+
uses: actions/checkout@v4
120126
with:
121127
fetch-depth: 0
122128

123129
# Set up git checkout
124130
- name: Set up git checkout
125131
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"
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'
129135
130136
branch_name='preview-${{ github.event.pull_request.number }}'
131137
git fetch --all
@@ -154,6 +160,9 @@ jobs:
154160
echo Toc-less status ${{steps.tocless.outcome}}
155161
exit 1
156162
163+
- name: Website preview for download
164+
run: zip website-preview.zip docs/* -r
165+
157166
# Commit the rendered bookdown files
158167
- name: Commit rendered bookdown files to preview branch
159168
id: commit
@@ -182,6 +191,8 @@ jobs:
182191
bookdown_link=$(echo "https://htmlpreview.github.io/?https://raw.githubusercontent.com/$GITHUB_REPOSITORY/preview-${{ github.event.pull_request.number }}/docs/index.html")
183192
tocless_link=$(echo "https://htmlpreview.github.io/?https://raw.githubusercontent.com/$GITHUB_REPOSITORY/preview-${{ github.event.pull_request.number }}/docs/no_toc/index.html")
184193
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
185196
echo "bookdown_link=$bookdown_link" >> $GITHUB_OUTPUT
186197
echo "tocless_link=$tocless_link" >> $GITHUB_OUTPUT
187198
echo "docx_link=$docx_link" >> $GITHUB_OUTPUT
@@ -197,11 +208,13 @@ jobs:
197208
issue-number: ${{ github.event.pull_request.number }}
198209
body: |
199210
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 }})
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 }})
203214
204-
_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 }}_
205218
edit-mode: replace
206219

207220
- name: Comment if no changes

0 commit comments

Comments
 (0)