-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (71 loc) · 2.61 KB
/
docker-build-push.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
# Based on
# - https://blog.jannikwempe.com/github-actions-trunk-based-development#heading-a-brief-introduction-to-trunk-based-development
# - https://blog.derlin.ch/github-actions-reusable-workflow-docker-images
name: Build & push docker image
on:
workflow_call:
inputs:
docker-image:
description: "Required input to set docker image name"
required: true
type: string
environment:
description: "Required input to set environment"
required: true
type: string
runs-on:
description: "Optional input to set an operating systems which the workflow uses. Defaults to ubuntu-latest if not set"
required: false
type: string
default: "ubuntu-latest"
docker-context:
description: "Optional input to set docker context"
required: false
type: string
default: "."
build-args:
description: "Optional input to set docker build-time variables"
required: false
type: string
default: ""
docker-platforms:
description: "Optional input list to set docker target platforms for build. Defaults to linux/amd64"
required: false
type: string
default: "linux/amd64"
latest-tag:
description: "Optional input to set enable latest tag"
required: false
type: boolean
default: false
push:
description: "Optional input can be set to specify whether the Docker image should be pushed to the registry. Defaults to false"
required: false
type: boolean
default: false
git-ref:
description: "Optional input to set git branch, tag or SHA to checkout"
required: false
type: string
default: ""
jobs:
docker-build-push:
name: Build & push docker image
runs-on: ${{inputs.runs-on}}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{inputs.git-ref}}
fetch-depth: ${{inputs.git-ref}} && 0 || 1 # In git-ref case: fetch all history for all branches and tags
- name: Build, tag & push docker image
uses: AplinkosMinisterija/reusable-workflows/.github/actions/docker-build-tag-push@main
with:
docker-image: ${{inputs.docker-image}}
environment: ${{inputs.environment}}
docker-context: ${{inputs.docker-context}}
build-args: ${{inputs.build-args}}
docker-platforms: ${{inputs.docker-platforms}}
latest-tag: ${{inputs.latest-tag}}
push: ${{inputs.push}}
registry-password: ${{secrets.GITHUB_TOKEN}}