Skip to content

Commit 1a7af04

Browse files
authored
Initial commit
0 parents  commit 1a7af04

136 files changed

Lines changed: 23775 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/switch_sync_repo.R

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env Rscript
2+
3+
# This script switches the repo entry for the yaml file to whatever is specified
4+
# Written by Candace Savonen Jan 2022
5+
6+
if (!("optparse" %in% installed.packages())){
7+
install.packages("optparse")
8+
}
9+
10+
library(optparse)
11+
12+
option_list <- list(
13+
optparse::make_option(
14+
c("--repo"),
15+
type = "character",
16+
default = "ottrproject/OTTR_Template_Test",
17+
help = "GitHub repository name, e.g. ottrproject/OTTR_Template_Test",
18+
)
19+
)
20+
21+
# Read the arguments passed
22+
opt_parser <- optparse::OptionParser(option_list = option_list)
23+
opt <- optparse::parse_args(opt_parser)
24+
25+
# Find .git root directory
26+
root_dir <- rprojroot::find_root(rprojroot::has_dir(".git"))
27+
28+
# Get test sync yaml path
29+
sync_file_path <- file.path(root_dir, ".github", "test-sync.yml")
30+
31+
yaml_contents <- yaml::yaml.load_file(sync_file_path)
32+
33+
# Only keep first grouping
34+
yaml_contents$group <- yaml_contents$group[[1]]
35+
36+
# Switch out repo
37+
yaml_contents$group$repos <- opt$repo
38+
39+
yaml::write_yaml(yaml_contents, sync_file_path)

.github/sync.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Candace Savonen Jan 2025
2+
# For info on how to update this file see: https://github.com/marketplace/actions/repo-file-sync-action#%EF%B8%8F-sync-configuration
3+
4+
group:
5+
- files:
6+
- source: .github/workflows/
7+
dest: .github/workflows/
8+
deleteOrphaned: true
9+
exclude: |
10+
transfer-rendered-files.yml
11+
send-updates.yml
12+
test-send-updates.yml
13+
starting-course.yml
14+
release-notes.yml
15+
docker-test.yml
16+
docker-build.yml
17+
- source: scripts/
18+
dest: scripts/
19+
deleteOrphaned: true
20+
- source: assets/box_images/
21+
dest: assets/box_images/
22+
- source: resources/exclude_files.txt
23+
dest: resources/exclude_files.txt
24+
- source: config_automation.yml
25+
dest: config_automation.yml
26+
# Repositories to receive changes
27+
repos: |
28+
jhudsl/Containers_for_Scientists
29+
30+
###ADD NEW REPO HERE following the format above#
31+
32+
### These are custom groups for syncing -- not all files needs to be synced
33+
- files:
34+
- source: config_automation.yml
35+
dest: config_automation.yml
36+
- source: .github/workflows/pull-request.yml
37+
dest: .github/workflows/pull-request.yml
38+
repos: |
39+
ottrproject/OTTR_Template_Quarto

.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 == 'true'}}
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: ottrproject/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/ottrproject/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"
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-build.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Candace Savonen Apr 2021
2+
3+
name: Build Docker
4+
5+
on:
6+
workflow_dispatch:
7+
inputs:
8+
dockerhubpush:
9+
description: 'Push to Dockerhub?'
10+
required: true
11+
default: 'false'
12+
tag:
13+
description: 'What tag to use?'
14+
required: true
15+
default: 'none'
16+
jobs:
17+
build-docker:
18+
name: Build Docker image
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: checkout repo
23+
uses: actions/checkout@v4
24+
25+
- name: Login as github actions bot
26+
run: |
27+
git config --global --add safe.directory $GITHUB_WORKSPACE
28+
git config --global user.name 'github-actions[bot]'
29+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
30+
31+
- name: Don't re-test if this is a sync branch
32+
run: |
33+
echo This was tested on OTTR_Template no need to re-run
34+
35+
# Set up Docker build
36+
- name: Set up Docker Buildx
37+
uses: docker/setup-buildx-action@v1
38+
39+
# Setup layer cache
40+
- name: Cache Docker layers
41+
uses: actions/cache@v2
42+
with:
43+
path: /tmp/.buildx-cache
44+
key: ${{ runner.os }}-buildx-${{ github.sha }}
45+
restore-keys: |
46+
${{ runner.os }}-buildx-
47+
48+
# Set up Docker build
49+
- name: Set up Docker Build
50+
if: ${{ github.head_ref != 'repo-sync/OTTR_Template/default' }}
51+
uses: docker/setup-buildx-action@v1
52+
53+
- name: Get token
54+
run: echo ${{ secrets.GH_PAT }} > docker/git_token.txt
55+
56+
# Build docker image
57+
- name: Build Docker image
58+
uses: docker/build-push-action@v2
59+
with:
60+
push: false
61+
load: true
62+
context: docker
63+
file: docker/Dockerfile
64+
tags: jhudsl/base_ottr
65+
66+
# Login to Dockerhub
67+
- name: Login to DockerHub
68+
if: ${{ github.event.inputs.dockerhubpush != 'false' }}
69+
uses: docker/login-action@v1
70+
with:
71+
username: ${{ secrets.DOCKERHUB_USERNAME }}
72+
password: ${{ secrets.DOCKERHUB_TOKEN }}
73+
74+
# Push the Docker image if set to true from a manual trigger
75+
- name: Push Docker image if manual trigger set to true
76+
if: ${{ github.event.inputs.dockerhubpush != 'false' }}
77+
run: |
78+
docker tag jhudsl/base_ottr:latest jhudsl/base_ottr:$github.event.inputs.tag
79+
docker push jhudsl/base_ottr:$github.event.inputs.tag

.github/workflows/docker-test.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
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 github actions bot
47+
run: |
48+
git config --global --add safe.directory $GITHUB_WORKSPACE
49+
git config --global user.name 'github-actions[bot]'
50+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
51+
52+
# Set up Docker build
53+
- name: Set up Docker Buildx
54+
uses: docker/setup-buildx-action@v1
55+
56+
# Setup layer cache
57+
- name: Cache Docker layers
58+
uses: actions/cache@v2
59+
with:
60+
path: /tmp/.buildx-cache
61+
key: ${{ runner.os }}-buildx-${{ github.sha }}
62+
restore-keys: |
63+
${{ runner.os }}-buildx-
64+
65+
- name: Set up Docker Build
66+
uses: docker/setup-buildx-action@v1
67+
68+
- name: Get token
69+
run: echo ${{ secrets.GH_PAT }} > ${{ inputs.directory }}/git_token.txt
70+
71+
- name: Build Docker image
72+
uses: docker/build-push-action@v2
73+
with:
74+
push: false
75+
load: true
76+
context: ${{ inputs.directory }}
77+
file: ${{ inputs.directory }}/Dockerfile
78+
tags: ${{ inputs.tag }}
79+
80+
# Login to Dockerhub
81+
- name: Login to DockerHub
82+
if: ${{ inputs.dockerhubpush != 'false' }}
83+
uses: docker/login-action@v1
84+
with:
85+
username: ${{ secrets.DOCKERHUB_USERNAME }}
86+
password: ${{ secrets.DOCKERHUB_TOKEN }}
87+
88+
# Push the Docker image if set to true from a manual trigger
89+
- name: Push Docker image if manual trigger set to true
90+
if: ${{ inputs.dockerhubpush != 'false' }}
91+
run: docker push ${{ inputs.tag }}

0 commit comments

Comments
 (0)