-
Notifications
You must be signed in to change notification settings - Fork 1
67 lines (57 loc) · 1.95 KB
/
build-image.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
name: Build & Push Docker Image
on:
push:
branches:
- master
release:
types: [published]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Extract ref/branch name
shell: bash
run: echo "##[set-output name=ref;]$(echo ${GITHUB_REF##*/})"
id: extract_ref
- name: Set timestamp
shell: bash
run: echo "::set-output name=time::$(date +%s)"
id: set_timestamp
- name: Login to Quay
uses: docker/login-action@v1
with:
registry: quay.io
username: cloudhut+github_push
password: ${{ secrets.QUAY_ENCRYPTED_PASS }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
# list of Docker images to use as base name for tags
images: |
quay.io/cloudhut/kowl
# generate Docker tags based on the following events/attributes
tags: |
type=raw,value=master
type=sha,prefix=master-,format=short
type=semver,pattern={{raw}},enable=${{ github.event.action == 'published' }}
# Use Buildx with moby/buildkit to utilize registry caching and more
# advanced building techniques (e.g. concurrent multistage builds)
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
driver-opts: image=moby/buildkit:v0.9.0,network=host
- name: Build and push Docker Image
uses: docker/build-push-action@v2
with:
context: .
push: true
build-args: |
KOWL_GIT_SHA=${{ github.sha }}
KOWL_GIT_REF=${{ steps.extract_ref.outputs.ref }}
KOWL_TIMESTAMP=${{ steps.set_timestamp.outputs.time }}
BUILT_FROM_PUSH=${{ github.event.action != 'published' }}
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max