generated from jhudsl/OTTR_Template_Website
-
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 #43 from jhudsl/repo-sync/OTTR_Template_Website/de…
…fault 🔄 Synced file(s) with jhudsl/OTTR_Template_Website
- Loading branch information
Showing
3 changed files
with
95 additions
and
45 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 |
---|---|---|
@@ -1,27 +1,90 @@ | ||
# Candace Savonen Apr 2021 | ||
|
||
name: Delete Preview | ||
# Candace Savonen Apr 2022 | ||
|
||
name: Build Docker Image | ||
|
||
on: | ||
pull_request: | ||
types: [closed] | ||
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: | ||
delete-preview: | ||
|
||
build-docker: | ||
name: Build Docker image | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: checkout repo | ||
uses: actions/checkout@v3 | ||
|
||
# This is because if a PR is closed before a render finishes it won't find it. | ||
- name: Sleep for 5 minutes | ||
run: sleep 300s | ||
shell: bash | ||
- name: Verify Dockerfiles changed? | ||
uses: tj-actions/[email protected] | ||
id: verify-changed-files | ||
with: | ||
files: | | ||
${{ inputs.directory }}/Dockerfile | ||
${{ inputs.directory }}/github_package_list.tsv | ||
# Check out current repository | ||
- name: checkout | ||
uses: actions/checkout@v3 | ||
- name: Login as jhudsl-robot | ||
run: | | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "jhudsl-robot" | ||
# 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: | ||
fetch-depth: 0 | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
# Delete the branch! | ||
- name: Delete branch locally and remotely | ||
run: git push origin --delete preview-${{ github.event.pull_request.number }} || echo "No branch to delete" | ||
# 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 }} |
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,5 +1,5 @@ | ||
# Candace Savonen Dec 2021 | ||
|
||
# Updated April 2023 | ||
name: Pull Request | ||
|
||
on: | ||
|
@@ -23,36 +23,21 @@ jobs: | |
with: | ||
files: config_automation.yml # Pass a space-separated list of configuration files. Rightmost files take precedence. | ||
|
||
- name: Make branch if it doesn't exist | ||
# Delete the branch if this has been run before | ||
- name: Delete branch locally and remotely | ||
run: git push origin --delete preview-${{ github.event.pull_request.number }} || echo "No branch to delete" | ||
|
||
# Make the branch fresh | ||
- name: Make the branch fresh | ||
run: | | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "jhudsl-robot" | ||
branch_name='preview-${{ github.event.pull_request.number }}' | ||
exists=$(git ls-remote https://${{ secrets.GH_PAT }}@github.com/$GITHUB_REPOSITORY $branch_name | wc -l | xargs) | ||
if [[ $exists == 0 ]];then | ||
echo branch doesnt exist | ||
git checkout -b $branch_name || echo branch exists | ||
git push --set-upstream origin $branch_name | ||
else | ||
echo branch does exist | ||
fi | ||
shell: bash | ||
|
||
- name: Check if this is a private repository | ||
id: public_repository | ||
run: | | ||
public=$(curl -Is https://github.com/${GITHUB_REPOSITORY} | head -1 | tr -dc '0-9') | ||
if [ $public -eq 2200 ];then | ||
public='true' | ||
echo 'public repository' | ||
else | ||
public='false' | ||
echo 'private repository' | ||
fi | ||
echo ::set-output name=public::$public | ||
echo branch doesnt exist | ||
git checkout -b $branch_name || echo branch exists | ||
git push --set-upstream origin $branch_name | ||
shell: bash | ||
|
||
outputs: | ||
public_repository: "${{ steps.public_repository.outputs.public }}" | ||
toggle_spell_check: "${{ env.SPELL_CHECK }}" | ||
|
@@ -80,7 +65,7 @@ jobs: | |
check_type: urls | ||
error_min: 0 | ||
gh_pat: secrets.GH_PAT | ||
|
||
render-preview: | ||
name: Render preview | ||
needs: yaml-check | ||
|
@@ -98,6 +83,7 @@ jobs: | |
# Set up git checkout | ||
- name: Set up git checkout | ||
run: | | ||
git config --system --add safe.directory $GITHUB_WORKSPACE | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "jhudsl-robot" | ||
|
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