-
Notifications
You must be signed in to change notification settings - Fork 1
357 lines (319 loc) · 12.2 KB
/
main.yml
File metadata and controls
357 lines (319 loc) · 12.2 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
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
name: Build and push images to registry
on:
push:
branches:
- main
tags:
- 'v*'
pull_request:
branches:
- main
workflow_dispatch:
inputs:
no_cache:
description: 'Force a rebuild of the Docker images without using cache.'
required: false
type: boolean
default: false
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
PUSH_IMAGE: ${{ github.event_name != 'pull_request' }}
jobs:
build-staging:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
outputs:
single-tag: ${{ steps.single-tag.outputs.single-tag }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Log in to the Container registry
if: env.PUSH_IMAGE == 'true'
uses: docker/login-action@v3.6.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata for staging
id: meta
uses: docker/metadata-action@v5.10.0
with:
images: ${{ env.REGISTRY }}/mardi4nfdi/wikibase-staging
tags: |
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest,enable={{is_default_branch}}
labels: |
org.opencontainers.image.description=Mediawiki/Wikibase image for the staging MaRDI portal
org.opencontainers.image.title=Staging Wikibase image
annotations: |
org.opencontainers.image.description=Mediawiki/Wikibase image for the staging MaRDI portal
org.opencontainers.image.title=Staging Wikibase image
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.12.0
- name: Build and push staging image
uses: docker/build-push-action@v6.18.0
with:
context: .
push: ${{ env.PUSH_IMAGE }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}
no-cache: ${{ github.event.inputs.no_cache || false }}
build-args: |
ENVIRONMENT=staging
cache-from: type=gha,scope=staging
cache-to: type=gha,mode=max,scope=staging
- name: Set single tag output
id: single-tag
run: |
echo "single-tag=ghcr.io/mardi4nfdi/wikibase-staging:latest" >> $GITHUB_OUTPUT
build-jobrunner-staging:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs: build-staging
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Log in to the Container registry
if: env.PUSH_IMAGE == 'true'
uses: docker/login-action@v3.6.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata for jobrunner staging
id: meta
uses: docker/metadata-action@v5.10.0
with:
images: ${{ env.REGISTRY }}/mardi4nfdi/redis-jobrunner-staging
tags: |
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest,enable={{is_default_branch}}
labels: |
org.opencontainers.image.description=Redis jobrunner for Mediawiki/Wikibase staging environment
org.opencontainers.image.title=Redis Jobrunner (staging)
annotations: |
org.opencontainers.image.description=Redis jobrunner for Mediawiki/Wikibase staging environment
org.opencontainers.image.title=Redis Jobrunner (staging)
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.12.0
- name: Build and push Docker jobrunner image
uses: docker/build-push-action@v6.18.0
with:
context: jobrunner
push: ${{ env.PUSH_IMAGE }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}
no-cache: ${{ github.event.inputs.no_cache || false }}
build-args: |
BASE_IMAGE=${{ needs.build-staging.outputs.single-tag }}
cache-from: type=gha,scope=jobrunner-staging
cache-to: type=gha,mode=max,scope=jobrunner-staging
build-production:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: read
packages: write
outputs:
single-tag: ${{ steps.single-tag.outputs.single-tag }}
steps:
- name: Start Measurement
uses: green-coding-solutions/eco-ci-energy-estimation@v5
with:
task: start-measurement
- name: Checkout
uses: actions/checkout@v6
- name: Checkout Repo Measurement
uses: green-coding-solutions/eco-ci-energy-estimation@v5
with:
task: get-measurement
label: 'repo checkout'
- name: Log in to the Container registry
uses: docker/login-action@v3.6.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata for production
id: meta
uses: docker/metadata-action@v5.10.0
with:
images: ${{ env.REGISTRY }}/mardi4nfdi/wikibase-production
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
labels: |
org.opencontainers.image.description=Mediawiki/Wikibase production-ready image for the MaRDI portal
org.opencontainers.image.title=MaRDI Portal Mediawiki/Wikibase image for Kubernetes
annotations: |
org.opencontainers.image.description=Mediawiki/Wikibase production-ready image for the MaRDI portal
org.opencontainers.image.title=MaRDI Portal Mediawiki/Wikibase image for Kubernetes
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.12.0
- name: Build and push production image
uses: docker/build-push-action@v6.18.0
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}
no-cache: ${{ github.event.inputs.no_cache || false }}
build-args: |
ENVIRONMENT=production
cache-from: type=gha,scope=production
cache-to: type=gha,mode=max,scope=production
- name: Set single tag output
id: single-tag
run: |
echo "single-tag=${{ fromJSON(steps.meta.outputs.json).tags[0] }}" >> $GITHUB_OUTPUT
- name: Tests measurement
uses: green-coding-solutions/eco-ci-energy-estimation@v5
with:
task: get-measurement
label: 'build and push'
- name: Show Energy Results
uses: green-coding-solutions/eco-ci-energy-estimation@v5
with:
task: display-results
build-jobrunner-production:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: read
packages: write
needs: build-production
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Log in to the Container registry
uses: docker/login-action@v3.6.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata for jobrunner production
id: meta
uses: docker/metadata-action@v5.10.0
with:
images: ${{ env.REGISTRY }}/mardi4nfdi/redis-jobrunner-production
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
labels: |
org.opencontainers.image.description=Redis jobrunner for Mediawiki/Wikibase production environment
org.opencontainers.image.title=Redis Jobrunner (production)
annotations: |
org.opencontainers.image.description=Redis jobrunner for Mediawiki/Wikibase production environment
org.opencontainers.image.title=Redis Jobrunner (production)
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.12.0
- name: Build and push jobrunner production image
uses: docker/build-push-action@v6.18.0
with:
context: jobrunner
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}
no-cache: ${{ github.event.inputs.no_cache || false }}
build-args: |
BASE_IMAGE=${{ needs.build-production.outputs.single-tag }}
cache-from: type=gha,scope=jobrunner-production
cache-to: type=gha,mode=max,scope=jobrunner-production
build-apache:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Log in to the Container registry
if: env.PUSH_IMAGE == 'true'
uses: docker/login-action@v3.6.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5.10.0
with:
images: ${{ env.REGISTRY }}/mardi4nfdi/apache
tags: |
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest,enable={{is_default_branch}}
labels: |
org.opencontainers.image.description=Apache reverse proxy for Mediawiki/Wikibase
org.opencontainers.image.title=Apache Proxy
annotations: |
org.opencontainers.image.description=Apache reverse proxy for Mediawiki/Wikibase
org.opencontainers.image.title=Apache Proxy
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.12.0
- name: Build and push Apache image
uses: docker/build-push-action@v6.18.0
with:
context: apache
push: ${{ env.PUSH_IMAGE }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}
no-cache: ${{ github.event.inputs.no_cache || false }}
cache-from: type=gha,scope=apache
cache-to: type=gha,mode=max,scope=apache
build-dev:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs: build-staging
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Log in to the Container registry
if: env.PUSH_IMAGE == 'true'
uses: docker/login-action@v3.6.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata for dev
id: meta
uses: docker/metadata-action@v5.10.0
with:
images: ${{ env.REGISTRY }}/mardi4nfdi/wikibase-dev
tags: |
type=raw,value=latest,enable={{is_default_branch}}
labels: |
org.opencontainers.image.title=Wikibase Development
org.opencontainers.image.description=Wikibase development environment with additional tools
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.12.0
- name: Build and push Docker dev image
uses: docker/build-push-action@v6.18.0
with:
context: dev
push: ${{ env.PUSH_IMAGE }}
tags: ${{ env.REGISTRY }}/mardi4nfdi/wikibase-dev:latest
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.labels }}
no-cache: ${{ github.event.inputs.no_cache || false }}
build-args: |
BASE_IMAGE=${{ needs.build-staging.outputs.single-tag }}
cache-from: type=gha,scope=dev
cache-to: type=gha,mode=max,scope=dev