Skip to content

Commit

Permalink
🔄 Synced local '.github/workflows/docker-test.yml' with remote '.gith…
Browse files Browse the repository at this point in the history
…ub/workflows/delete-preview.yml'

release-null
  • Loading branch information
cansavvy committed Feb 20, 2024
1 parent 37579a2 commit b6d3934
Showing 1 changed file with 16 additions and 79 deletions.
95 changes: 16 additions & 79 deletions .github/workflows/docker-test.yml
Original file line number Diff line number Diff line change
@@ -1,90 +1,27 @@
# Candace Savonen Apr 2021

# Candace Savonen Apr 2022

name: Build Docker Image
name: Delete Preview

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
pull_request:
types: [closed]

jobs:

build-docker:
name: Build Docker image
delete-preview:
runs-on: ubuntu-latest

steps:
- name: checkout repo
uses: actions/checkout@v3

- name: Verify Dockerfiles changed?
uses: tj-actions/[email protected]
id: verify-changed-files
with:
files: |
${{ inputs.directory }}/Dockerfile
${{ inputs.directory }}/github_package_list.tsv
- 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
# 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

# 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
# Check out current repository
- name: checkout
uses: actions/checkout@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
fetch-depth: 0

# 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 }}
# 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"

0 comments on commit b6d3934

Please sign in to comment.