-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from fhdsl/cansavvy/gha-updates
Add GHA file updates
- Loading branch information
Showing
9 changed files
with
810 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
name: Periodic URL Check | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: '0 0 1 * *' | ||
|
||
jobs: | ||
set-up: | ||
name: Load user automation choices | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
# Use the yaml-env-action action. | ||
- name: Load environment from YAML | ||
uses: doughepi/[email protected] | ||
with: | ||
files: config_automation.yml # Pass a space-separated list of configuration files. Rightmost files take precedence. | ||
outputs: | ||
toggle_url_check_periodically: "${{ env.URL_CHECK_PERIODICALLY }}" | ||
|
||
url-check: | ||
name: Check URLs | ||
needs: set-up | ||
if: ${{needs.set-up.outputs.toggle_url_check_periodically == 'yes'}} | ||
runs-on: ubuntu-latest | ||
container: | ||
image: jhudsl/base_ottr:main | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
# Delete the branch if this has been run before | ||
- name: Delete branch locally and remotely | ||
run: git push origin --delete preview-spell-error || echo "No branch to delete" | ||
|
||
# Make the branch fresh | ||
- name: Make the branch fresh | ||
run: | | ||
git config --global --add safe.directory $GITHUB_WORKSPACE | ||
git config --global user.name 'github-actions[bot]' | ||
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | ||
echo branch doesnt exist | ||
git checkout -b preview-spell-error || echo branch exists | ||
git push --set-upstream origin preview-spell-error || echo echo branch exists remotely | ||
shell: bash | ||
|
||
- name: Run the check | ||
uses: jhudsl/ottr-reports@main | ||
id: check_results | ||
continue-on-error: true | ||
with: | ||
check_type: urls | ||
error_min: 1 | ||
|
||
- name: Declare file path and time | ||
id: check-report | ||
run: | | ||
error_num=$(cat check_reports/url_checks.tsv | wc -l) | ||
error_num="$((error_num-1))" | ||
echo "error_num=$error_num" >> $GITHUB_OUTPUT | ||
echo "error_url=https://github.com/${GITHUB_REPOSITORY}/blob/preview-spell-error/check_reports/url_checks.tsv" >> $GITHUB_OUTPUT | ||
shell: bash | ||
|
||
- name: Stop if failure | ||
if: steps.check_results.outcome == 'failure' | ||
run: exit 1 | ||
|
||
- name: Print out error variables | ||
run: | | ||
echo ${{ steps.check-report.outputs.error_url }} | ||
echo ${{ steps.check-report.outputs.error_num }} | ||
- name: Find issues | ||
id: find-issue | ||
env: | ||
GH_PAT: ${{ secrets.GH_PAT }} | ||
run: | | ||
echo "$GITHUB_REPOSITORY" | ||
curl -o find_issue.R https://raw.githubusercontent.com/jhudsl/ottr-reports/main/scripts/find_issue.R | ||
issue_exists=$(Rscript --vanilla find_issue.R --repo $GITHUB_REPOSITORY --git_pat $GH_PAT) | ||
echo URL issue exists: $issue_exists | ||
echo "issue_existence=$issue_exists" >> $GITHUB_OUTPUT | ||
- name: If too many URL errors, then make an issue | ||
if: ${{ steps.check-report.outputs.error_num >= 1 && steps.find-issue.outputs.issue_existence == 0}} | ||
uses: JasonEtco/create-an-issue@v2 | ||
with: | ||
filename: .github/ISSUE_TEMPLATE/url-error.md | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
FILE_URL: ${{ steps.check-report.outputs.error_url }} | ||
ERROR_NUM: ${{ steps.check-report.outputs.error_num }} | ||
|
||
- name: If no URL errors than delete the branch we made | ||
if: ${{ steps.check-report.outputs.error_num < 1 }} | ||
run: | | ||
git config --system --add safe.directory "$GITHUB_WORKSPACE" | ||
git push origin --delete preview-spell-error || echo "No branch to delete" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# Candace Savonen Apr 2021 | ||
|
||
name: Delete Preview | ||
|
||
on: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# Candace Savonen Apr 2021 | ||
|
||
name: Build Docker | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
dockerhubpush: | ||
description: 'Push to Dockerhub?' | ||
required: true | ||
default: 'false' | ||
tag: | ||
description: 'What tag to use?' | ||
required: true | ||
default: 'none' | ||
jobs: | ||
build-docker: | ||
name: Build Docker image | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: checkout repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Login as github actions bot | ||
run: | | ||
git config --global --add safe.directory $GITHUB_WORKSPACE | ||
git config --global user.name 'github-actions[bot]' | ||
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | ||
- name: Don't re-test if this is a sync branch | ||
run: | | ||
echo This was tested on OTTR_Template no need to re-run | ||
# Set up Docker build | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
# Setup layer cache | ||
- name: Cache Docker layers | ||
uses: actions/cache@v2 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-buildx- | ||
# Set up Docker build | ||
- name: Set up Docker Build | ||
if: ${{ github.head_ref != 'repo-sync/OTTR_Template/default' }} | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Get token | ||
run: echo ${{ secrets.GH_PAT }} > docker/git_token.txt | ||
|
||
# Build docker image | ||
- name: Build Docker image | ||
uses: docker/build-push-action@v2 | ||
with: | ||
push: false | ||
load: true | ||
context: docker | ||
file: docker/Dockerfile | ||
tags: jhudsl/base_ottr | ||
|
||
# Login to Dockerhub | ||
- name: Login to DockerHub | ||
if: ${{ github.event.inputs.dockerhubpush != 'false' }} | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
# Push the Docker image if set to true from a manual trigger | ||
- name: Push Docker image if manual trigger set to true | ||
if: ${{ github.event.inputs.dockerhubpush != 'false' }} | ||
run: | | ||
docker tag jhudsl/base_ottr:latest jhudsl/base_ottr:$github.event.inputs.tag | ||
docker push jhudsl/base_ottr:$github.event.inputs.tag |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
|
||
# Candace Savonen Apr 2022 | ||
|
||
name: Build Docker Image | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
directory: | ||
required: true | ||
type: string | ||
tag: | ||
required: true | ||
type: string | ||
dockerhubpush: | ||
description: 'Push to Dockerhub?' | ||
required: false | ||
default: 'false' | ||
type: string | ||
secrets: | ||
GH_PAT: | ||
required: true | ||
DOCKERHUB_USERNAME: | ||
required: false | ||
DOCKERHUB_TOKEN: | ||
required: false | ||
|
||
jobs: | ||
|
||
build-docker: | ||
name: Build Docker image | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: checkout repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Verify Dockerfiles changed? | ||
uses: tj-actions/verify-changed-files@v17 | ||
id: verify-changed-files | ||
with: | ||
files: | | ||
${{ inputs.directory }}/Dockerfile | ||
${{ inputs.directory }}/github_package_list.tsv | ||
- name: Login as github actions bot | ||
run: | | ||
git config --global --add safe.directory $GITHUB_WORKSPACE | ||
git config --global user.name 'github-actions[bot]' | ||
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | ||
# Set up Docker build | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
# Setup layer cache | ||
- name: Cache Docker layers | ||
uses: actions/cache@v2 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-buildx- | ||
- name: Set up Docker Build | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Get token | ||
run: echo ${{ secrets.GH_PAT }} > ${{ inputs.directory }}/git_token.txt | ||
|
||
- name: Build Docker image | ||
uses: docker/build-push-action@v2 | ||
with: | ||
push: false | ||
load: true | ||
context: ${{ inputs.directory }} | ||
file: ${{ inputs.directory }}/Dockerfile | ||
tags: ${{ inputs.tag }} | ||
|
||
# Login to Dockerhub | ||
- name: Login to DockerHub | ||
if: ${{ inputs.dockerhubpush != 'false' }} | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
# Push the Docker image if set to true from a manual trigger | ||
- name: Push Docker image if manual trigger set to true | ||
if: ${{ inputs.dockerhubpush != 'false' }} | ||
run: docker push ${{ inputs.tag }} |
Oops, something went wrong.