35
35
RUN_TMATE : ${{ secrets.RUN_TMATE }}
36
36
37
37
jobs :
38
+ diagnostics :
39
+ name : Run diagnostics
40
+ runs-on : ubuntu-latest
41
+ steps :
42
+ # Note that a duplicate of this step must be added at the top of
43
+ # each job.
44
+ - id : harden-runner
45
+ name : Harden the runner
46
+ uses : step-security/harden-runner@v2
47
+ with :
48
+ egress-policy : audit
49
+ - id : github-status
50
+ name : Check GitHub status
51
+ uses : crazy-max/ghaction-github-status@v3
52
+ - id : dump-context
53
+ name : Dump context
54
+ uses : crazy-max/ghaction-dump-context@v2
38
55
lint :
39
56
# Checks out the source and runs pre-commit hooks. Detects coding errors
40
57
# and style deviations.
41
- name : " Lint sources"
58
+ name : Lint sources
59
+ needs :
60
+ - diagnostics
42
61
runs-on : ubuntu-latest
43
62
steps :
63
+ - id : harden-runner
64
+ name : Harden the runner
65
+ uses : step-security/harden-runner@v2
66
+ with :
67
+ egress-policy : audit
44
68
- id : setup-env
45
69
uses : cisagov/setup-env-github-action@develop
46
- - uses : actions/checkout@v3
70
+ - uses : actions/checkout@v4
47
71
- id : setup-python
48
72
uses : actions/setup-python@v4
49
73
with :
@@ -104,11 +128,26 @@ jobs:
104
128
- uses : hashicorp/setup-terraform@v2
105
129
with :
106
130
terraform_version : ${{ steps.setup-env.outputs.terraform-version }}
131
+ - name : Install go-critic
132
+ env :
133
+ PACKAGE_URL : github.com/go-critic/go-critic/cmd/gocritic
134
+ PACKAGE_VERSION : ${{ steps.setup-env.outputs.go-critic-version }}
135
+ run : go install ${PACKAGE_URL}@${PACKAGE_VERSION}
136
+ - name : Install gosec
137
+ env :
138
+ PACKAGE_URL : github.com/securego/gosec/v2/cmd/gosec
139
+ PACKAGE_VERSION : ${{ steps.setup-env.outputs.gosec-version }}
140
+ run : go install ${PACKAGE_URL}@${PACKAGE_VERSION}
107
141
- name : Install shfmt
108
142
env :
109
143
PACKAGE_URL : mvdan.cc/sh/v3/cmd/shfmt
110
144
PACKAGE_VERSION : ${{ steps.setup-env.outputs.shfmt-version }}
111
145
run : go install ${PACKAGE_URL}@${PACKAGE_VERSION}
146
+ - name : Install staticcheck
147
+ env :
148
+ PACKAGE_URL : honnef.co/go/tools/cmd/staticcheck
149
+ PACKAGE_VERSION : ${{ steps.setup-env.outputs.staticcheck-version }}
150
+ run : go install ${PACKAGE_URL}@${PACKAGE_VERSION}
112
151
- name : Install Terraform-docs
113
152
env :
114
153
PACKAGE_URL : github.com/terraform-docs/terraform-docs
@@ -166,18 +205,25 @@ jobs:
166
205
# with the value specified by the user.
167
206
#
168
207
# Scheduled builds are tagged with `:nightly`.
169
- name : " Prepare build variables"
170
- runs-on : ubuntu-latest
208
+ name : Prepare build variables
209
+ needs :
210
+ - diagnostics
171
211
outputs :
172
212
created : ${{ steps.prep.outputs.created }}
173
213
repometa : ${{ steps.repo.outputs.result }}
174
214
source_version : ${{ steps.prep.outputs.source_version }}
175
215
tags : ${{ steps.prep.outputs.tags }}
216
+ runs-on : ubuntu-latest
176
217
steps :
177
- - uses : actions/checkout@v3
218
+ - id : harden-runner
219
+ name : Harden the runner
220
+ uses : step-security/harden-runner@v2
221
+ with :
222
+ egress-policy : audit
223
+ - uses : actions/checkout@v4
178
224
- name : Gather repository metadata
179
225
id : repo
180
- uses : actions/github-script@v6
226
+ uses : actions/github-script@v7
181
227
with :
182
228
script : |
183
229
const repo = await github.rest.repos.get(context.repo)
@@ -228,16 +274,23 @@ jobs:
228
274
build :
229
275
# Builds a single test image for the native platform. This image is saved
230
276
# as an artifact and loaded by the test job.
231
- name : " Build test image"
277
+ name : Build test image
278
+ needs :
279
+ - diagnostics
280
+ - prepare
232
281
runs-on : ubuntu-latest
233
- needs : [prepare]
234
282
steps :
283
+ - id : harden-runner
284
+ name : Harden the runner
285
+ uses : step-security/harden-runner@v2
286
+ with :
287
+ egress-policy : audit
235
288
- name : Checkout
236
- uses : actions/checkout@v3
289
+ uses : actions/checkout@v4
237
290
- name : Set up QEMU
238
- uses : docker/setup-qemu-action@v2
291
+ uses : docker/setup-qemu-action@v3
239
292
- name : Set up Docker Buildx
240
- uses : docker/setup-buildx-action@v2
293
+ uses : docker/setup-buildx-action@v3
241
294
- name : Cache Docker layers
242
295
uses : actions/cache@v3
243
296
env :
@@ -251,7 +304,7 @@ jobs:
251
304
run : mkdir -p dist
252
305
- name : Build image
253
306
id : docker_build
254
- uses : docker/build-push-action@v4
307
+ uses : docker/build-push-action@v5
255
308
with :
256
309
build-args : |
257
310
VERSION=${{ needs.prepare.outputs.source_version }}
@@ -260,6 +313,11 @@ jobs:
260
313
context : .
261
314
file : ./Dockerfile
262
315
outputs : type=docker,dest=dist/image.tar
316
+ # Uncomment the following option if you are building an image for use
317
+ # on Google Cloud Run or AWS Lambda. The current default image output
318
+ # is unable to run on either. Please see the following issue for more
319
+ # information: https://github.com/docker/buildx/issues/1533
320
+ # provenance: false
263
321
tags : ${{ env.IMAGE_NAME }}:latest # not to be pushed
264
322
# For a list of pre-defined annotation keys and value types see:
265
323
# https://github.com/opencontainers/image-spec/blob/master/annotations.md
@@ -298,11 +356,18 @@ jobs:
298
356
if : env.RUN_TMATE
299
357
test :
300
358
# Executes tests on the single-platform image created in the "build" job.
301
- name : " Test image"
359
+ name : Test image
360
+ needs :
361
+ - diagnostics
362
+ - build
302
363
runs-on : ubuntu-latest
303
- needs : [build]
304
364
steps :
305
- - uses : actions/checkout@v3
365
+ - id : harden-runner
366
+ name : Harden the runner
367
+ uses : step-security/harden-runner@v2
368
+ with :
369
+ egress-policy : audit
370
+ - uses : actions/checkout@v4
306
371
- id : setup-python
307
372
uses : actions/setup-python@v4
308
373
with :
@@ -344,32 +409,41 @@ jobs:
344
409
# GitHub Container Registry. The contents of README.md are pushed as the
345
410
# image's description to Docker Hub. This job is skipped when the
346
411
# triggering event is a pull request.
347
- name : " Build and push all platforms"
348
- runs-on : ubuntu-latest
349
- needs : [lint, prepare, test]
350
412
if : github.event_name != 'pull_request'
413
+ name : Build and push all platforms
414
+ needs :
415
+ - diagnostics
416
+ - lint
417
+ - prepare
418
+ - test
351
419
# When Dependabot creates a PR it requires this permission in
352
420
# order to push Docker images to ghcr.io.
353
421
permissions :
354
422
packages : write
423
+ runs-on : ubuntu-latest
355
424
steps :
425
+ - id : harden-runner
426
+ name : Harden the runner
427
+ uses : step-security/harden-runner@v2
428
+ with :
429
+ egress-policy : audit
356
430
- name : Login to Docker Hub
357
- uses : docker/login-action@v2
431
+ uses : docker/login-action@v3
358
432
with :
359
433
username : ${{ secrets.DOCKER_USERNAME }}
360
434
password : ${{ secrets.DOCKER_PASSWORD }}
361
435
- name : Login to GitHub Container Registry
362
- uses : docker/login-action@v2
436
+ uses : docker/login-action@v3
363
437
with :
364
438
registry : ghcr.io
365
439
username : ${{ github.actor }}
366
440
password : ${{ secrets.GITHUB_TOKEN }}
367
441
- name : Checkout
368
- uses : actions/checkout@v3
442
+ uses : actions/checkout@v4
369
443
- name : Set up QEMU
370
- uses : docker/setup-qemu-action@v2
444
+ uses : docker/setup-qemu-action@v3
371
445
- name : Set up Docker Buildx
372
- uses : docker/setup-buildx-action@v2
446
+ uses : docker/setup-buildx-action@v3
373
447
- name : Cache Docker layers
374
448
uses : actions/cache@v3
375
449
env :
@@ -383,7 +457,7 @@ jobs:
383
457
run : ./buildx-dockerfile.sh
384
458
- name : Build and push platform images to registries
385
459
id : docker_build
386
- uses : docker/build-push-action@v4
460
+ uses : docker/build-push-action@v5
387
461
with :
388
462
build-args : |
389
463
VERSION=${{ needs.prepare.outputs.source_version }}
@@ -392,6 +466,11 @@ jobs:
392
466
context : .
393
467
file : ./Dockerfile-x
394
468
platforms : ${{ env.PLATFORMS }}
469
+ # Uncomment the following option if you are building an image for use
470
+ # on Google Cloud Run or AWS Lambda. The current default image output
471
+ # is unable to run on either. Please see the following issue for more
472
+ # information: https://github.com/docker/buildx/issues/1533
473
+ # provenance: false
395
474
push : true
396
475
tags : ${{ needs.prepare.outputs.tags }}
397
476
# For a list of pre-defined annotation keys and value types see:
0 commit comments