-
Notifications
You must be signed in to change notification settings - Fork 4.8k
369 lines (361 loc) · 13.6 KB
/
uffizzi-cluster-build.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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
name: Preview (build)
on:
pull_request:
types: [opened,reopened,synchronize,closed]
paths-ignore:
- 'docs/'
- '.md'
- 'tests/'
- '!tests/.sh'
- '!tests/apitests/'
- '!tests/ci/'
permissions:
contents: read
pull-requests: write
id-token: write
actions: write
jobs:
# Job to build-push harbor-core image
build-harbor-core:
name: Build and Push `harbor-core` Image
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' && github.event.action != 'closed' }}
outputs:
tags: ${{ steps.meta.outputs.tags }}
steps:
- name: Checkout git repo
uses: actions/checkout@v3
- name: Make versions dir
run: |
make compile
- name: Make harbor_core
run: |
make compile_core
- name: Generate UUID image name
id: uuid
run: echo "UUID_CORE=$(uuidgen)" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
# An anonymous, emphemeral registry built on ttl.sh
images: registry.uffizzi.com/${{ env.UUID_CORE }}
tags: type=raw,value=60d
- name: Build and Push Image to Uffizzi Ephemeral Registry
uses: docker/build-push-action@v3
with:
cache-from: type=gha
cache-to: type=gha,mode=max
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: ./make/photon/core/Dockerfile
context: .
build-args: |
harbor_base_image_version=dev
harbor_base_namespace=goharbor
npm_registry=https://registry.npmjs.org
# Job to build-push harbor-portal image
build-harbor-portal:
name: Build and Push `harbor-portal` Image
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' && github.event.action != 'closed' }}
outputs:
tags: ${{ steps.meta.outputs.tags }}
steps:
- name: Checkout git repo
uses: actions/checkout@v3
- name: Generate UUID image name
id: uuid
run: echo "UUID_PORTAL=$(uuidgen)" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
# An anonymous, emphemeral registry built on ttl.sh
images: registry.uffizzi.com/${{ env.UUID_PORTAL }}
tags: type=raw,value=60d
- name: Build and Push Image to Uffizzi Ephemeral Registry
uses: docker/build-push-action@v3
with:
cache-from: type=gha
cache-to: type=gha,mode=max
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: ./make/photon/portal/Dockerfile
context: .
build-args: |
harbor_base_image_version=dev
harbor_base_namespace=goharbor
npm_registry=https://registry.npmjs.org
- name: Echo image
run: echo ${{ steps.meta.outputs.images }}
# Job to build-push harbor-jobservice image
build-harbor-jobservice:
name: Build and Push `harbor-jobservice` Image
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' && github.event.action != 'closed' }}
outputs:
tags: ${{ steps.meta.outputs.tags }}
steps:
- name: Checkout git repo
uses: actions/checkout@v3
- name: Make harbor_jobservice file
run: |
make compile
- name: Generate UUID image name
id: uuid
run: echo "UUID_JS=$(uuidgen)" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
# An anonymous, emphemeral registry built on ttl.sh
images: registry.uffizzi.com/${{ env.UUID_JS }}
tags: type=raw,value=60d
- name: Build and Push Image to Uffizzi Ephemeral Registry
uses: docker/build-push-action@v3
with:
cache-from: type=gha
cache-to: type=gha,mode=max
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: ./make/photon/jobservice/Dockerfile
context: .
build-args: |
harbor_base_image_version=dev
harbor_base_namespace=goharbor
npm_registry=https://registry.npmjs.org
# Job to build-push harbor-registry image
build-harbor-registry:
name: Build and Push `harbor-registry` Image
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' && github.event.action != 'closed' }}
outputs:
tags: ${{ steps.meta.outputs.tags }}
steps:
- name: Checkout git repo
uses: actions/checkout@v3
- name: Make registry file
run: |
make build -e BUILDTARGET="_build_registry"
- name: Generate UUID image name
id: uuid
run: echo "UUID_REG=$(uuidgen)" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
# An anonymous, emphemeral registry built on ttl.sh
images: registry.uffizzi.com/${{ env.UUID_REG }}
tags: type=raw,value=60d
- name: Build and Push Image to Uffizzi Ephemeral Registry
uses: docker/build-push-action@v3
with:
cache-from: type=gha
cache-to: type=gha,mode=max
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: ./make/photon/registry/Dockerfile
context: .
build-args: |
harbor_base_image_version=dev
harbor_base_namespace=goharbor
npm_registry=https://registry.npmjs.org
# Job to build-push harbor-registryctl image
build-harbor-registryctl:
name: Build and Push `harbor-registryctl` Image
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' && github.event.action != 'closed' }}
outputs:
tags: ${{ steps.meta.outputs.tags }}
steps:
- name: Checkout git repo
uses: actions/checkout@v3
- name: Make registry file
run: |
make build -e BUILDTARGET="_build_registry"
- name: Compile registryctl file
run: |
make compile_registryctl
- name: Generate UUID image name
id: uuid
run: echo "UUID_REGCTL=$(uuidgen)" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
# An anonymous, emphemeral registry built on ttl.sh
images: registry.uffizzi.com/${{ env.UUID_REGCTL }}
tags: type=raw,value=60d
- name: Build and Push Image to Uffizzi Ephemeral Registry
uses: docker/build-push-action@v3
with:
cache-from: type=gha
cache-to: type=gha,mode=max
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: ./make/photon/registryctl/Dockerfile
context: .
build-args: |
harbor_base_image_version=dev
harbor_base_namespace=goharbor
npm_registry=https://registry.npmjs.org
# Job to build-push harbor-db image
build-harbor-db:
name: Build and Push `harbor-db` Image
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' && github.event.action != 'closed' }}
outputs:
tags: ${{ steps.meta.outputs.tags }}
steps:
- name: Checkout git repo
uses: actions/checkout@v3
- name: Build DB
run: |
make build -e BUILDTARGET="_build_db"
- name: Generate UUID image name
id: uuid
run: echo "UUID_DB=$(uuidgen)" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
# An anonymous, emphemeral registry built on ttl.sh
images: registry.uffizzi.com/${{ env.UUID_DB }}
tags: type=raw,value=60d
- name: Build and Push Image to Uffizzi Ephemeral Registry
uses: docker/build-push-action@v3
with:
cache-from: type=gha
cache-to: type=gha,mode=max
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: ./make/photon/db/Dockerfile
context: .
build-args: |
harbor_base_image_version=dev
harbor_base_namespace=goharbor
npm_registry=https://registry.npmjs.org
# Job to build-push harbor-redis image
build-harbor-redis:
name: Build and Push `harbor-redis` Image
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' && github.event.action != 'closed' }}
outputs:
tags: ${{ steps.meta.outputs.tags }}
steps:
- name: Checkout git repo
uses: actions/checkout@v3
- name: Build DB
run: |
make build -e BUILDTARGET="_build_redis"
- name: Generate UUID image name
id: uuid
run: echo "UUID_RDS=$(uuidgen)" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
# An anonymous, emphemeral registry built on ttl.sh
images: registry.uffizzi.com/${{ env.UUID_RDS }}
tags: type=raw,value=60d
- name: Build and Push Image to Uffizzi Ephemeral Registry
uses: docker/build-push-action@v3
with:
cache-from: type=gha
cache-to: type=gha,mode=max
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: ./make/photon/redis/Dockerfile
context: .
build-args: |
harbor_base_image_version=dev
harbor_base_namespace=goharbor
npm_registry=https://registry.npmjs.org
# Render values file
render-values:
name: Render values file
needs:
- build-harbor-core
- build-harbor-portal
- build-harbor-jobservice
- build-harbor-registry
- build-harbor-registryctl
- build-harbor-db
- build-harbor-redis
runs-on: ubuntu-latest
steps:
- name: Export values from needs
id: yq
run: |
export REPO_core=$(echo ${{ needs.build-harbor-core.outputs.tags }} | cut -f1 -d":")
export REPO_portal=$(echo ${{ needs.build-harbor-portal.outputs.tags }} | cut -f1 -d":")
export REPO_jobservice=$(echo ${{ needs.build-harbor-jobservice.outputs.tags }} | cut -f1 -d":")
export REPO_registry=$(echo ${{ needs.build-harbor-registry.outputs.tags }} | cut -f1 -d":")
export REPO_registryctl=$(echo ${{ needs.build-harbor-registryctl.outputs.tags }} | cut -f1 -d":")
export REPO_db=$(echo ${{ needs.build-harbor-db.outputs.tags }} | cut -f1 -d":")
export REPO_redis=$(echo ${{ needs.build-harbor-redis.outputs.tags }} | cut -f1 -d":")
touch values.yaml
yq eval ".expose.tls.certSource = \"none\"" -i values.yaml
yq eval ".core.image.repository = \"$REPO_core\"" -i values.yaml
yq eval ".core.image.tag |= \"60d\"" -i values.yaml
yq eval ".portal.image.repository = \"$REPO_portal\"" -i values.yaml
yq eval ".portal.image.tag |= \"60d\"" -i values.yaml
yq eval ".jobservice.image.repository = \"$REPO_jobservice\"" -i values.yaml
yq eval ".jobservice.image.tag |= \"60d\"" -i values.yaml
yq eval ".registry.registry.image.repository = \"$REPO_registry\"" -i values.yaml
yq eval ".registry.registry.image.tag |= \"60d\"" -i values.yaml
yq eval ".registry.controller.image.repository |= \"$REPO_registryctl\"" -i values.yaml
yq eval ".registry.controller.image.tag |= \"60d\"" -i values.yaml
yq eval ".database.internal.image.repository = \"$REPO_db\"" -i values.yaml
yq eval ".database.internal.image.tag |= \"60d\"" -i values.yaml
yq eval ".redis.internal.image.repository = \"$REPO_redis\"" -i values.yaml
yq eval ".redis.internal.image.tag |= \"60d\"" -i values.yaml
- name: Upload values as artifact
uses: actions/upload-artifact@v3
with:
name: preview-spec
path: values.yaml
retention-days: 2
- name: Upload PR Event as Artifact
uses: actions/upload-artifact@v3
with:
name: preview-spec
path: ${{ github.event_path }}
retention-days: 2
uffizzi-cluster-delete:
if: ${{ github.event_name == 'pull_request' && github.event.action == 'closed' }}
runs-on: ubuntu-latest
steps:
- name: Delete Virtual Cluster
uses: UffizziCloud/cluster-action@main
with:
action: delete
cluster-name: pr-${{ github.event.pull_request.number }}
- name: Upload PR Event as Artifact
uses: actions/upload-artifact@v3
with:
name: preview-spec
path: ${{ github.event_path }}
retention-days: 2