-
-
Notifications
You must be signed in to change notification settings - Fork 111
410 lines (391 loc) · 13.6 KB
/
container-ci.yml
File metadata and controls
410 lines (391 loc) · 13.6 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
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
name: Docker container CI
on:
workflow_call:
inputs:
variant:
required: true
type: string
secrets:
DOCKERHUB_ACCESS_TOKEN:
description: Docker Hub access token
DOCKERHUB_USERNAME:
description: Docker Hub username
GITHUB_TOKEN:
description: GitHub token
permissions:
contents: read
jobs:
revisions:
runs-on: ubuntu-24.04
outputs:
weblate_sha: ${{ steps.get_sha.outputs.sha }}
weblate_date: ${{ steps.get_date.outputs.date }}
steps:
- id: get_sha
run: echo "sha=$(git ls-remote --quiet https://github.com/WeblateOrg/weblate.git HEAD | awk '{print $1}')" >> "$GITHUB_OUTPUT"
- id: get_date
run: echo "date=$(date --iso-8601=ns)" >> "$GITHUB_OUTPUT"
build:
needs:
- revisions
uses: ./.github/workflows/container-build.yml
with:
variant: ${{ inputs.variant }}
architecture: amd64
weblate_sha: ${{needs.revisions.outputs.weblate_sha}}
weblate_date: ${{needs.revisions.outputs.weblate_date}}
buildx:
needs:
- revisions
uses: ./.github/workflows/container-build.yml
with:
variant: ${{ inputs.variant }}
architecture: arm64
weblate_sha: ${{needs.revisions.outputs.weblate_sha}}
weblate_date: ${{needs.revisions.outputs.weblate_date}}
test-basic:
needs:
- revisions
- build
uses: ./.github/workflows/container-test.yml
with:
variant: ${{ inputs.variant }}
test: basic
weblate_sha: ${{needs.revisions.outputs.weblate_sha}}
weblate_date: ${{needs.revisions.outputs.weblate_date}}
test-novolume:
needs:
- revisions
- build
uses: ./.github/workflows/container-test.yml
with:
variant: ${{ inputs.variant }}
test: read-write
weblate_sha: ${{needs.revisions.outputs.weblate_sha}}
weblate_date: ${{needs.revisions.outputs.weblate_date}}
test-localtime:
needs:
- revisions
- build
uses: ./.github/workflows/container-test.yml
with:
variant: ${{ inputs.variant }}
test: localtime
weblate_sha: ${{needs.revisions.outputs.weblate_sha}}
weblate_date: ${{needs.revisions.outputs.weblate_date}}
test-saml:
needs:
- revisions
- build
uses: ./.github/workflows/container-test.yml
with:
variant: ${{ inputs.variant }}
test: saml
weblate_sha: ${{needs.revisions.outputs.weblate_sha}}
weblate_date: ${{needs.revisions.outputs.weblate_date}}
test-split:
needs:
- revisions
- build
uses: ./.github/workflows/container-test.yml
with:
variant: ${{ inputs.variant }}
test: split
weblate_sha: ${{needs.revisions.outputs.weblate_sha}}
weblate_date: ${{needs.revisions.outputs.weblate_date}}
test-single-celery:
needs:
- revisions
- build
uses: ./.github/workflows/container-test.yml
with:
variant: ${{ inputs.variant }}
test: celery-single
weblate_sha: ${{needs.revisions.outputs.weblate_sha}}
weblate_date: ${{needs.revisions.outputs.weblate_date}}
test-ssl:
needs:
- revisions
- build
uses: ./.github/workflows/container-test.yml
with:
variant: ${{ inputs.variant }}
test: basic
port: 4443
protocol: https
weblate_sha: ${{needs.revisions.outputs.weblate_sha}}
weblate_date: ${{needs.revisions.outputs.weblate_date}}
anchore:
runs-on: ubuntu-24.04
name: Anchore Container Scan
needs:
- revisions
- build
permissions:
security-events: write
env:
MATRIX_ARCHITECTURE: linux/amd64
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- name: Expose GitHub Runtime
uses: crazy-max/ghaction-github-runtime@3cb05d89e1f492524af3d41a1c98c83bc3025124 # v3.1.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0
with:
# renovate: datasource=github-releases depName=docker/buildx
version: v0.23.0
- uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
with:
name: Docker cache amd64
path: /tmp/.buildx-cache/linux/amd64
- name: Adjust bleeding edge image
if: inputs.variant == 'bleeding'
run: .github/bin/bleeding "$WEBLATE_SHA" "$WEBLATE_DATE"
env:
WEBLATE_SHA: ${{ needs.revisions.outputs.weblate_sha }}
WEBLATE_DATE: ${{ needs.revisions.outputs.weblate_date }}
- name: Build the Docker image
run: .github/bin/docker-build load
- name: List Docker images
run: docker image ls --all
- name: Checkout the code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- name: Anchore scan action
uses: anchore/scan-action@7c05671ae9be166aeb155bad2d7df9121823df32 # v6.1.0
id: scan
with:
image: weblate/weblate:test
fail-build: false
- name: Upload Anchore Scan Report
uses: github/codeql-action/upload-sarif@45775bd8235c68ba998cffa5171334d58593da47 # v3.28.15
with:
sarif_file: ${{ steps.scan.outputs.sarif }}
trivy:
runs-on: ubuntu-24.04
name: Trivy Container Scan
needs:
- revisions
- build
permissions:
security-events: write
env:
MATRIX_ARCHITECTURE: linux/amd64
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- name: Expose GitHub Runtime
uses: crazy-max/ghaction-github-runtime@3cb05d89e1f492524af3d41a1c98c83bc3025124 # v3.1.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0
with:
# renovate: datasource=github-releases depName=docker/buildx
version: v0.23.0
- uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
with:
name: Docker cache amd64
path: /tmp/.buildx-cache/linux/amd64
- name: Adjust bleeding edge image
if: inputs.variant == 'bleeding'
run: .github/bin/bleeding "$WEBLATE_SHA" "$WEBLATE_DATE"
env:
WEBLATE_SHA: ${{ needs.revisions.outputs.weblate_sha }}
WEBLATE_DATE: ${{ needs.revisions.outputs.weblate_date }}
- name: Build the Docker image
run: .github/bin/docker-build load
- name: List Docker images
run: docker image ls --all
- name: Checkout the code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@6c175e9c4083a92bbca2f9724c8a5e33bc2d97a5 # 0.30.0
with:
image-ref: weblate/weblate:test
format: sarif
output: trivy-results.sarif
severity: CRITICAL,HIGH
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@45775bd8235c68ba998cffa5171334d58593da47 # v3.28.15
with:
sarif_file: trivy-results.sarif
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: Trivy scan SARIF
path: trivy-results.sarif
merge:
runs-on: ubuntu-24.04
name: Merge images, ${{ inputs.variant }}
needs:
- build
- buildx
- revisions
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- name: Set up QEMU
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
with:
platforms: all
- name: Expose GitHub Runtime
uses: crazy-max/ghaction-github-runtime@3cb05d89e1f492524af3d41a1c98c83bc3025124 # v3.1.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0
with:
# renovate: datasource=github-releases depName=docker/buildx
version: v0.23.0
- uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
with:
name: Docker cache amd64
path: /tmp/.buildx-cache/linux/amd64
- uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
with:
name: Docker cache arm64
path: /tmp/.buildx-cache/linux/arm64
- name: Adjust bleeding edge image
if: inputs.variant == 'bleeding'
run: .github/bin/bleeding "$WEBLATE_SHA" "$WEBLATE_DATE"
env:
WEBLATE_SHA: ${{ needs.revisions.outputs.weblate_sha }}
WEBLATE_DATE: ${{ needs.revisions.outputs.weblate_date }}
- name: Configure Docker build
run: .github/bin/get-buildx-args
- name: Merge the Docker images
run: .github/bin/docker-build
tests-all:
runs-on: ubuntu-24.04
name: Tests, ${{ inputs.variant }}
needs:
- test-basic
- test-saml
- test-split
- test-single-celery
- test-novolume
- test-ssl
- test-localtime
steps:
# This is dependency only job to collect all test results
- run: echo
lint-all:
runs-on: ubuntu-24.04
name: Lint, ${{ inputs.variant }}
needs:
- anchore
- trivy
steps:
# This is dependency only job to collect all lint results
- run: echo
push_dockerhub:
runs-on: ubuntu-24.04
name: Publish to Docker Hub, ${{ inputs.variant }}
needs:
- tests-all
- lint-all
- merge
- revisions
if: ${{ (startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/main')) && github.repository == 'WeblateOrg/docker' }}
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- name: Set up QEMU
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
with:
platforms: all
- name: Expose GitHub Runtime
uses: crazy-max/ghaction-github-runtime@3cb05d89e1f492524af3d41a1c98c83bc3025124 # v3.1.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0
with:
# renovate: datasource=github-releases depName=docker/buildx
version: v0.23.0
- uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
with:
name: Docker cache amd64
path: /tmp/.buildx-cache/linux/amd64
- uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
with:
name: Docker cache arm64
path: /tmp/.buildx-cache/linux/arm64
- name: DockerHub login
run: echo "${{ secrets.DOCKERHUB_ACCESS_TOKEN }}" | docker login --username "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin
- name: Adjust bleeding edge image
if: inputs.variant == 'bleeding'
run: .github/bin/bleeding "$WEBLATE_SHA" "$WEBLATE_DATE"
env:
WEBLATE_SHA: ${{ needs.revisions.outputs.weblate_sha }}
WEBLATE_DATE: ${{ needs.revisions.outputs.weblate_date }}
- name: Configure Docker build
run: .github/bin/get-buildx-args "publish-$WEBLATE_VARIANT"
env:
WEBLATE_VARIANT: ${{ inputs.variant }}
- name: Publish the Docker images
run: .github/bin/docker-build "publish-$WEBLATE_VARIANT"
env:
WEBLATE_VARIANT: ${{ inputs.variant }}
push_github:
runs-on: ubuntu-24.04
name: Publish to GitHub, ${{ inputs.variant }}
permissions:
packages: write
needs:
- tests-all
- lint-all
- merge
- revisions
if: ${{ (startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/main')) && github.repository == 'WeblateOrg/docker' }}
env:
DOCKER_IMAGE: ghcr.io/weblateorg/weblate
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- name: Set up QEMU
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
with:
platforms: all
- name: Expose GitHub Runtime
uses: crazy-max/ghaction-github-runtime@3cb05d89e1f492524af3d41a1c98c83bc3025124 # v3.1.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0
with:
# renovate: datasource=github-releases depName=docker/buildx
version: v0.23.0
- uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
with:
name: Docker cache amd64
path: /tmp/.buildx-cache/linux/amd64
- uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
with:
name: Docker cache arm64
path: /tmp/.buildx-cache/linux/arm64
- name: Login to GitHub Container Registry
if: ${{ github.event_name != 'pull_request'}}
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Adjust bleeding edge image
if: inputs.variant == 'bleeding'
run: .github/bin/bleeding "$WEBLATE_SHA" "$WEBLATE_DATE"
env:
WEBLATE_SHA: ${{ needs.revisions.outputs.weblate_sha }}
WEBLATE_DATE: ${{ needs.revisions.outputs.weblate_date }}
- name: Configure Docker build
run: .github/bin/get-buildx-args "publish-$WEBLATE_VARIANT"
env:
WEBLATE_VARIANT: ${{ inputs.variant }}
- name: Publish the Docker images
run: .github/bin/docker-build "publish-$WEBLATE_VARIANT"
env:
WEBLATE_VARIANT: ${{ inputs.variant }}