-
Notifications
You must be signed in to change notification settings - Fork 17
180 lines (165 loc) · 5.6 KB
/
bld_docker.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
name: bld_docker
permissions:
checks: write
contents: read
issues: read
pull-requests: write
on:
workflow_call:
inputs:
docker_name:
description: 'Name of the docker image to build'
required: false
default: "orcid/version-bumping-test"
type: string
context:
description: 'Name of the context in the repo'
required: false
default: "."
type: string
build_args:
description: 'build_args e.g wibble=blar'
required: false
default: ""
type: string
file:
description: 'specify a custom dockerfile'
required: false
default: ""
type: string
version_tag:
description: 'Name of the tag to build'
required: false
default: 'latest'
type: string
bump:
description: 'whether to bump the version number by a major minor patch amount or none'
required: false
default: 'patch'
type: string
ref:
description: 'git reference to use with the checkout use default_branch to have that calculated'
required: false
default: "default"
type: string
push:
description: 'Select to push to docker registry'
required: false
default: true
type: boolean
workflow_dispatch:
inputs:
docker_name:
description: 'Name of the docker image to build'
required: false
default: "orcid/version-bumping-test"
type: string
context:
description: 'Name of the context in the repo'
required: false
default: "."
type: string
build_args:
description: 'build_args e.g wibble=blar'
required: false
default: ""
type: string
file:
description: 'specify a custom dockerfile'
required: false
default: ""
type: string
version_tag:
description: 'Name of the tag to build'
required: false
default: 'latest'
type: string
bump:
description: 'whether to bump the version number by a major minor patch amount or none'
required: false
default: 'patch'
type: string
ref:
description: 'git reference to use with the checkout use default_branch to have that calculated'
required: false
default: "default"
type: string
push:
description: 'Select to push to docker registry'
required: false
default: true
type: boolean
jobs:
bld_docker:
strategy:
matrix:
include:
- artifact_name: prod
docker_name: orcid/registry/orcid-web-frontend-prod
build_args: "build_env=prod"
file: Dockerfile.build.yarn
- artifact_name: sandbox
docker_name: orcid/registry/orcid-web-frontend-sandbox
build_args: "build_env=sandbox"
file: Dockerfile.build.yarn
- artifact_name: qa
docker_name: orcid/registry/orcid-web-frontend-qa
build_args: "build_env=qa"
file: Dockerfile.build.yarn
- artifact_name: int
docker_name: orcid/registry/orcid-web-frontend-int
build_args: "build_env=int"
file: Dockerfile.build.yarn
runs-on: ubuntu-latest
steps:
- name: git-checkout-ref-action
id: ref
uses: ORCID/git-checkout-ref-action@main
with:
default_branch: ${{ github.event.repository.default_branch }}
ref: ${{ inputs.ref }}
- uses: actions/checkout@v4
with:
ref: ${{ steps.ref.outputs.ref }}
# checkout some history so we can scan commits for bump messages
# NOTE: history does not include tags!
fetch-depth: 100
- name: find next version
id: version
uses: ORCID/version-bump-action@main
with:
version_tag: ${{ inputs.version_tag }}
bump: ${{ inputs.bump }}
- uses: docker/setup-buildx-action@v3
- uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
# each cache needs a unique key for the job
key: ${{ runner.os }}-buildx-${{ hashFiles(inputs.context) }}
# Alternative restore keys if no exact match is found
# I /think/ this means that other docker buildx jobs could help out here
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to private registry
uses: docker/login-action@v3
with:
registry: ${{ secrets.DOCKER_REG_PRIVATE }}
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: nasty hack to allow dynamic defaults
id: dynamic_defaults
run: |
FILE="${{ matrix.file }}"
echo "default_file=${FILE:-${{ inputs.context }}/Dockerfile}" >> "$GITHUB_OUTPUT"
- name: show the dynamic defaults
run: |
echo ${{ steps.dynamic_defaults.outputs.default_file }}
- uses: docker/build-push-action@v6
with:
push: ${{ inputs.push }}
tags: ${{ secrets.DOCKER_REG_PRIVATE }}/${{ matrix.docker_name}}:${{ steps.version.outputs.version_tag_numeric }}
context: ${{ inputs.context }}
cache-from: type=registry,ref=${{ secrets.DOCKER_REG_PRIVATE }}/${{ matrix.docker_name }}:cache
cache-to: type=registry,mode=max,image-manifest=true,oci-mediatypes=true,ref=${{ secrets.DOCKER_REG_PRIVATE }}/${{ matrix.docker_name }}:cache
build-args: ${{ matrix.build_args }}
file: ${{ steps.dynamic_defaults.outputs.default_file }}