generated from jhudsl/OTTR_Template_Website
-
Notifications
You must be signed in to change notification settings - Fork 1
90 lines (75 loc) · 2.34 KB
/
docker-test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# 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 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:
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 }}