-
Notifications
You must be signed in to change notification settings - Fork 0
102 lines (94 loc) · 3 KB
/
docker.yaml
File metadata and controls
102 lines (94 loc) · 3 KB
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
96
97
98
99
100
101
102
name: build-push
on:
workflow_call:
inputs:
image:
description: 'Image name'
required: true
type: 'string'
tag:
description: 'Name for docker tag'
required: false
type: 'string'
default: 'latest'
push:
description: 'Push image'
required: false
type: 'boolean'
default: false
context:
description: 'Docker build context path'
required: false
type: 'string'
default: '.'
dockerfile:
description: 'Dockerfile path'
required: false
type: 'string'
default: 'Dockerfile'
dockerhub_shortdesc:
description: 'Short description for DockerHub repository'
required: false
type: 'string'
default: 'Radicalbit AI Monitoring'
dockerhub_enable_url_completion:
description: 'Whether we should enable completion of relative URLs to absolute ones'
required: false
type: 'boolean'
default: true
dockerhub_push_latest:
description: 'Whether we should push a "latest" tag in addition to the provided one'
required: false
type: 'boolean'
default: false
secrets:
USERNAME:
description: 'Registry username'
required: true
PASSWORD:
description: 'Registry password'
required: true
ORGANIZATION:
description: 'Registry organization'
required: true
jobs:
build-push:
runs-on: ubuntu-22.04
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Registry
uses: docker/login-action@v3
with:
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
- name: Set build tags
id: set-build-tags
run: |
tags="${{ secrets.ORGANIZATION }}/${{ inputs.image }}:${{ inputs.tag }}"
if [ "${{ inputs.dockerhub_push_latest }}" = "true" ]; then
tags="$tags,${{ secrets.ORGANIZATION }}/${{ inputs.image }}:latest"
fi
echo "tags=$tags" >> $GITHUB_ENV
- name: Log
run: |
echo Building tags: ${{ env.tags }}
- name: Build and push image
uses: docker/build-push-action@v5
with:
context: ${{ inputs.context }}
file: ${{ inputs.context }}/${{ inputs.dockerfile }}
push: ${{ inputs.push }}
tags: ${{ env.tags }}
platforms: linux/amd64,linux/arm64
- name: Docker Hub Description
if: ${{ inputs.push }}
uses: peter-evans/dockerhub-description@v4
with:
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
repository: ${{ secrets.ORGANIZATION }}/${{ inputs.image }}
short-description: ${{ inputs.dockerhub_shortdesc }}
enable-url-completion: ${{ inputs.dockerhub_enable_url_completion }}