Skip to content

Commit 8a2bec5

Browse files
Merge pull request #21 from jhudsl/after_deletion
Ottrfying
2 parents e5f86c7 + b069ddd commit 8a2bec5

File tree

10 files changed

+540
-11
lines changed

10 files changed

+540
-11
lines changed

.github/workflows/check-url.yml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
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+
url_error_min: "${{ env.URL_ERROR_MIN }}"
26+
27+
url-check:
28+
name: Check URLs
29+
needs: set-up
30+
if: ${{needs.set-up.outputs.toggle_url_check_periodically == 'true'}}
31+
runs-on: ubuntu-latest
32+
outputs:
33+
status: ${{ steps.check_results.outcome }}
34+
35+
steps:
36+
37+
- name: Run the check
38+
uses: ottrproject/ottr-reports@main
39+
id: check_results
40+
continue-on-error: true
41+
with:
42+
check_spelling: false
43+
spelling_error_min: 1
44+
check_urls: true
45+
url_error_min: ${{needs.set-up.outputs.url_error_min}}
46+
check_quiz_form: false
47+
quiz_error_min: 1
48+
sort_dictionary: false
49+
50+
issue-maker:
51+
name: Create issue
52+
needs: url-check
53+
if: needs.url-check.outputs.status == 'failure' # Proceed to make an issue if the checker above failed anywhere
54+
runs-on: ubuntu-latest
55+
steps:
56+
57+
- name: Checkout
58+
uses: actions/checkout@v4
59+
with:
60+
fetch-depth: 0
61+
62+
# Delete the branch if this has been run before
63+
- name: Delete branch locally and remotely
64+
run: git push origin --delete periodic-url-error || echo "No branch to delete"
65+
66+
# Make the branch fresh
67+
- name: Make the branch fresh
68+
run: |
69+
git config --global --add safe.directory $GITHUB_WORKSPACE
70+
git config --global user.name 'github-actions[bot]'
71+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
72+
73+
echo branch doesnt exist
74+
git checkout -b periodic-url-error || echo branch exists
75+
git push --set-upstream origin periodic-url-error || echo echo branch exists remotely
76+
shell: bash
77+
78+
- name: Download artifact
79+
uses: actions/download-artifact@v4
80+
with:
81+
name: ottr-check-reports
82+
83+
- name: Declare file path and time
84+
id: check-report
85+
run: |
86+
error_num=$(cat url_checks.tsv | wc -l)
87+
error_num="$((error_num-1))"
88+
echo "error_num=$error_num" >> $GITHUB_OUTPUT
89+
echo "error_url=https://github.com/${GITHUB_REPOSITORY}/blob/periodic-url-error/url_checks.tsv" >> $GITHUB_OUTPUT
90+
shell: bash
91+
92+
- name: Print out error variables
93+
run: |
94+
echo ${{ steps.check-report.outputs.error_url }}
95+
echo ${{ steps.check-report.outputs.error_num }}
96+
97+
- name: Commit URL errors file
98+
env:
99+
GH_PAT: ${{ secrets.GH_PAT }}
100+
run: |
101+
git add --force url_checks.tsv
102+
git commit -m 'Add URL check file' || echo "No changes to commit"
103+
git push --set-upstream origin periodic-url-error || echo echo branch exists remotely
104+
105+
- name: Make the issue
106+
uses: JasonEtco/create-an-issue@v2
107+
with:
108+
filename: .github/ISSUE_TEMPLATE/url-error.md
109+
env:
110+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
111+
FILE_URL: ${{ steps.check-report.outputs.error_url }}
112+
ERROR_NUM: ${{ steps.check-report.outputs.error_num }}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Candace Savonen Apr 2021
2+
3+
name: Delete Preview
4+
5+
on:
6+
pull_request:
7+
types: [closed]
8+
9+
jobs:
10+
delete-preview:
11+
runs-on: ubuntu-latest
12+
steps:
13+
14+
# This is because if a PR is closed before a render finishes it won't find it.
15+
- name: Sleep for 5 minutes
16+
run: sleep 300s
17+
shell: bash
18+
19+
# Check out current repository
20+
- name: checkout
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
25+
# Delete the branch!
26+
- name: Delete branch locally and remotely
27+
run: git push origin --delete preview-${{ github.event.pull_request.number }} || echo "No branch to delete"

.github/workflows/docker-test.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
2+
# Candace Savonen Apr 2022
3+
4+
name: Build Docker Image
5+
6+
on:
7+
workflow_dispatch:
8+
inputs:
9+
directory:
10+
required: true
11+
type: string
12+
tag:
13+
required: true
14+
type: string
15+
dockerhubpush:
16+
description: 'Push to Dockerhub?'
17+
required: false
18+
default: 'false'
19+
type: string
20+
secrets:
21+
GH_PAT:
22+
required: true
23+
DOCKERHUB_USERNAME:
24+
required: false
25+
DOCKERHUB_TOKEN:
26+
required: false
27+
28+
jobs:
29+
30+
build-docker:
31+
name: Build Docker image
32+
runs-on: ubuntu-latest
33+
34+
steps:
35+
- name: checkout repo
36+
uses: actions/checkout@v4
37+
38+
- name: Verify Dockerfiles changed?
39+
uses: tj-actions/verify-changed-files@v17
40+
id: verify-changed-files
41+
with:
42+
files: |
43+
${{ inputs.directory }}/Dockerfile
44+
${{ inputs.directory }}/github_package_list.tsv
45+
46+
- name: Login as jhudsl-robot
47+
run: |
48+
git config --local user.email "itcrtrainingnetwork@gmail.com"
49+
git config --local user.name "jhudsl-robot"
50+
51+
# Set up Docker build
52+
- name: Set up Docker Buildx
53+
uses: docker/setup-buildx-action@v1
54+
55+
# Setup layer cache
56+
- name: Cache Docker layers
57+
uses: actions/cache@v2
58+
with:
59+
path: /tmp/.buildx-cache
60+
key: ${{ runner.os }}-buildx-${{ github.sha }}
61+
restore-keys: |
62+
${{ runner.os }}-buildx-
63+
64+
- name: Set up Docker Build
65+
uses: docker/setup-buildx-action@v1
66+
67+
- name: Get token
68+
run: echo ${{ secrets.GH_PAT }} > ${{ inputs.directory }}/git_token.txt
69+
70+
- name: Build Docker image
71+
uses: docker/build-push-action@v2
72+
with:
73+
push: false
74+
load: true
75+
context: ${{ inputs.directory }}
76+
file: ${{ inputs.directory }}/Dockerfile
77+
tags: ${{ inputs.tag }}
78+
79+
# Login to Dockerhub
80+
- name: Login to DockerHub
81+
if: ${{ inputs.dockerhubpush != 'false' }}
82+
uses: docker/login-action@v1
83+
with:
84+
username: ${{ secrets.DOCKERHUB_USERNAME }}
85+
password: ${{ secrets.DOCKERHUB_TOKEN }}
86+
87+
# Push the Docker image if set to true from a manual trigger
88+
- name: Push Docker image if manual trigger set to true
89+
if: ${{ inputs.dockerhubpush != 'false' }}
90+
run: docker push ${{ inputs.tag }}

.github/workflows/pull_request.yml

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
# Candace Savonen 2021
2+
# Updated May 2025
3+
4+
name: Pull Request
5+
6+
on:
7+
pull_request:
8+
branches: [ main, staging ]
9+
10+
jobs:
11+
12+
yaml-check:
13+
name: Load user automation choices
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
# Install dependencies
22+
- name: Install system dependencies for spatial R packages
23+
run: |
24+
sudo apt-get update
25+
sudo apt-get install -y gdal-bin libgdal-dev libproj-dev libgeos-dev libudunits2-dev cmake
26+
27+
# Use the yaml-env-action action.
28+
- name: Load environment from YAML
29+
uses: doughepi/yaml-env-action@v1.0.0
30+
with:
31+
files: config_automation.yml # Pass a space-separated list of configuration files. Rightmost files take precedence.
32+
33+
# Delete the branch if this has been run before
34+
- name: Delete branch locally and remotely
35+
run: git push origin --delete preview-${{ github.event.pull_request.number }} || echo "No branch to delete"
36+
37+
# Make the branch fresh
38+
- name: Make the branch fresh
39+
run: |
40+
git config --global --add safe.directory $GITHUB_WORKSPACE
41+
git config --global user.name 'github-actions[bot]'
42+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
43+
44+
branch_name='preview-${{ github.event.pull_request.number }}'
45+
echo branch doesnt exist
46+
git checkout -b $branch_name || echo branch exists
47+
git push --set-upstream origin $branch_name || echo branch exists remotely
48+
shell: bash
49+
50+
51+
outputs:
52+
toggle_website: "${{ env.RENDER_WEBSITE }}"
53+
toggle_spell_check: "${{ env.SPELL_CHECK }}"
54+
spell_error_min: "${{ env.SPELL_ERROR_MIN }}"
55+
toggle_style_code: "${{ env.STYLE_CODE }}"
56+
toggle_url_check: "${{ env.URL_CHECKER }}"
57+
url_error_min: "${{ env.URL_ERROR_MIN }}"
58+
toggle_quiz_check: "${{ env.CHECK_QUIZZES }}"
59+
quiz_error_min: "${{ env.QUIZ_ERROR_MIN }}"
60+
toggle_md_linter: "${{ env.MARKDOWN_LINTER }}"
61+
toggle_readability: "${{ env.READABILITY_REPORT }}"
62+
toggle_render_preview: "${{ env.RENDER_PREVIEW }}"
63+
toggle_dictionary_sort: "${{ env.DICTIONARY_SORT }}"
64+
rendering_docker_image: "${{ env.RENDERING_DOCKER_IMAGE }}"
65+
66+
########################## Make the error reports ##############################
67+
ottr-reports:
68+
name: Run Reports
69+
needs: yaml-check
70+
if: ${{needs.yaml-check.outputs.toggle_spell_check == 'true' || needs.yaml-check.outputs.toggle_url_check == 'true' || needs.yaml-check.outputs.toggle_quiz_check == 'true'}}
71+
runs-on: ubuntu-latest
72+
permissions:
73+
pull-requests: write
74+
75+
steps:
76+
- name: Checkout Actions Repository
77+
uses: actions/checkout@v4
78+
with:
79+
fetch-depth: 0
80+
81+
- name: Run Reports
82+
id: run-reports
83+
uses: ottrproject/ottr-reports@main
84+
with:
85+
check_spelling: ${{needs.yaml-check.outputs.toggle_spell_check}}
86+
spelling_error_min: ${{needs.yaml-check.outputs.spell_error_min}}
87+
check_urls: ${{needs.yaml-check.outputs.toggle_url_check}}
88+
url_error_min: ${{needs.yaml-check.outputs.url_error_min}}
89+
check_quiz_form: ${{needs.yaml-check.outputs.toggle_quiz_check}}
90+
quiz_error_min: ${{needs.yaml-check.outputs.quiz_error_min}}
91+
sort_dictionary: ${{needs.yaml-check.outputs.toggle_dictionary_sort}}
92+
93+
############################# Style the code ###################################
94+
style-code:
95+
name: Style code
96+
needs: yaml-check
97+
runs-on: ubuntu-latest
98+
if: ${{needs.yaml-check.outputs.toggle_style_code == 'true'}}
99+
container:
100+
image: jhudsl/base_ottr:main
101+
102+
steps:
103+
- name: Checkout files
104+
uses: actions/checkout@v4
105+
with:
106+
fetch-depth: 0
107+
108+
- name: Run styler
109+
run: Rscript -e "styler::style_file(list.files(pattern = '(R|q)md$', recursive = FALSE, full.names = TRUE));warnings()"
110+
111+
- name: Commit styled files
112+
run: |
113+
git config --system --add safe.directory "$GITHUB_WORKSPACE"
114+
git add \*md
115+
git commit -m 'Style *mds' || echo "No changes to commit"
116+
git push origin || echo "No changes to commit"
117+
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 == 'true'}}
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+
138+
############################# Render Preview ###################################
139+
render-preview:
140+
name: Render preview
141+
needs: yaml-check
142+
runs-on: ubuntu-latest
143+
if: ${{needs.yaml-check.outputs.toggle_render_preview == 'true'}}
144+
permissions:
145+
pull-requests: write
146+
contents: write
147+
148+
steps:
149+
- name: Checkout repo
150+
uses: actions/checkout@v4
151+
with:
152+
fetch-depth: 0
153+
# Install dependencies
154+
- name: Install system dependencies for spatial R packages
155+
run: |
156+
sudo apt-get update
157+
sudo apt-get install -y gdal-bin libgdal-dev libproj-dev libgeos-dev libudunits2-dev cmake
158+
159+
- name: Run render
160+
uses: ottrproject/ottr-preview@main
161+
with:
162+
toggle_website: ${{needs.yaml-check.outputs.toggle_website}}
163+
docker_image: ${{needs.yaml-check.outputs.rendering_docker_image}}

0 commit comments

Comments
 (0)