Skip to content

Commit 742eede

Browse files
authored
Merge pull request #18 from jhudsl/repo-sync/AnVIL_Template/default
🔄 Synced file(s) with jhudsl/AnVIL_Template
2 parents 90ba8e4 + 722b510 commit 742eede

31 files changed

+440
-690
lines changed

.github/AnVIL_Feedback_Script.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
# Extract the title from the YAML front matter of index.Rmd
4+
title=$(awk '/^title:/{gsub(/^title: /,""); print}' "index.Rmd" | grep -v '^$')
5+
6+
# Remove the outside quotation marks
7+
title=$(sed -e 's/^"//' -e 's/"$//' <<< "$title")
8+
9+
# Replace spaces with '+'
10+
title=${title// /+}
11+
12+
# Base url for the AnVIL Google Form
13+
url_base="https://docs.google.com/forms/d/e/1FAIpQLScrDVb_utm55pmb_SHx-RgELTEbCCWdLea0T3IzS0Oj00GE4w/viewform?usp=pp_url&entry.1565230805="
14+
15+
# Replace the url inside _output.yml
16+
perl -i -pe 's|https://docs.google.com/forms/d/e/1FAIpQLScrDVb_utm55pmb_SHx-RgELTEbCCWdLea0T3IzS0Oj00GE4w/viewform\?usp=pp_url&entry\.1565230805=.*"> Click|'${url_base}${title}'"> Click|g' _output.yml
17+
18+
# Print for Github actions
19+
echo "The feedback link is: ${url_base}${title}"

.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/yaml-env-action@v1.0.0
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

0 commit comments

Comments
 (0)