-
Notifications
You must be signed in to change notification settings - Fork 0
62 lines (62 loc) · 1.87 KB
/
docker-publish.yaml
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
name: Docker Publish Workflow
on:
workflow_call:
inputs:
# Mandatory inputs
# Image name to publish
imageName:
required: TRUE
type: string
githubRef:
required: true
type: string
gitSha:
required: true
type: string
# Optional finetuning inputs
# Path to the docker context
path:
required: False
type: string
default: .
# Path to the dockerfile (relative to `path`)
dockerfile:
required: False
type: string
default: Dockerfile
# If enabled, will cache_from the latest version of the docker image.
cache:
required: False
type: boolean
default: true
secrets:
DOCKER_USERNAME:
required: true
DOCKER_PASSWORD:
required: true
jobs:
docker-publish:
name: Docker Publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: buildx-publish-landing
- uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build/Publish
uses: docker/build-push-action@v2
with:
context: ${{ inputs.path }}
file: ${{ inputs.path }}/${{ inputs.dockerfile }}
push: ${{ inputs.githubRef == 'refs/heads/master' }}
cache-from: ${{ inputs.cache && 'type=local,src=/tmp/.buildx-cache,type=registry,ref=pennlabs/${{ inputs.imageName }}:latest' }}
cache-to: ${{ inputs.cache && 'type=local,dest=/tmp/.buildx-cache' }}
tags: ${{ inputs.imageName }}:latest,${{ inputs.imageName }}:${{ inputs.gitSha }}