-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (93 loc) · 2.88 KB
/
docker-output-publish.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
91
92
93
94
95
name: Docker output publish
on:
workflow_call:
inputs:
artifact-name:
description: "Name of artifact to get"
required: true
type: string
build-args:
description: "Docker build args"
required: false
type: string
docker-image:
description: "Name of the docker image to push"
required: true
type: string
docker-tag:
description: "Tag of the docker image to push, defaults to current branch name"
required: false
type: string
default: ""
docker-platforms:
description: "List of comma separated platforms to build"
required: false
type: string
default: "linux/amd64"
runs-on:
description: "Runner to use"
required: false
type: string
default: "ubuntu-latest"
secrets:
docker-repo:
description: "Docker registry to push to"
required: true
docker-username:
description: "Docker username"
required: true
docker-token:
description: "Docker token"
required: true
outputs:
image-digest:
description: "Pushed docker image's digest"
value: ${{ jobs.publish.outputs.digest }}
jobs:
publish:
name: Docker - Publish
runs-on: ["ubuntu-latest", "${{ inputs.runs-on }}"]
concurrency: docker-${{ inputs.docker-tag }}
outputs:
digest: ${{ steps.docker_build.outputs.digest }}
steps:
- name: Checkout source
uses: actions/[email protected]
- uses: actions/[email protected]
name: Download artifact
with:
name: ${{ inputs.artifact-name }}
- name: Set up QEMU
uses: docker/[email protected]
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Login on registry
uses: docker/[email protected]
with:
registry: ${{ secrets.docker-repo }}
username: ${{ secrets.docker-username }}
password: ${{ secrets.docker-token }}
- name: Calculate image tag
id: image-tag
run: |
if [ -z "${{ inputs.docker-tag }}" ]; then
echo "tag=${GITHUB_REF##*/}" >> "$GITHUB_OUTPUT"
else
echo "tag=${{ inputs.docker-tag }}" >> "$GITHUB_OUTPUT"
fi
- name: Build and push
id: docker_build
uses: docker/[email protected]
with:
context: .
push: true
tags: |
${{ secrets.docker-repo }}/${{ inputs.docker-image }}:${{ steps.image-tag.outputs.tag }}
platforms: ${{ inputs.docker-platforms }}
build-args: |
BUILDX_QEMU_ENV=true
${{ inputs.build-args }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}