-
Notifications
You must be signed in to change notification settings - Fork 5
645 lines (617 loc) · 25.2 KB
/
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
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
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
name: Build
permissions:
contents: read
packages: write
on:
workflow_call:
inputs:
ref:
type: string
required: true
build-api-image:
description: Whether to build a `api_serve` Docker image.
type: boolean
default: true
build-api-functions:
description: Whether to build zip artifacts for API functions.
type: boolean
default: true
build-console-image:
description: Whether to build a RedwoodJS console Docker image.
type: boolean
default: true
build-python-functions:
description: Whether to build zip artifacts for Python functions.
type: boolean
default: true
build-web:
description: Whether to build website distribution artifacts for the client package.
type: boolean
default: true
api-image-name:
description: Name of the docker image. Use caution when setting a non-default value.
type: string
default: ${{ github.repository }}-api
api-function-artifact-retention-days:
description: Number of days to retain API function build artifacts.
type: number
default: 90
console-image-name:
description: Name of the docker image. Use caution when setting a non-default value.
type: string
default: ${{ github.repository }}-console
docker-image-args-ref:
description: Ref name for the build commit, like refs/heads/my-feature-branch-1.
type: string
required: true
docker-image-artifacts-retention-days:
description: Number of days to store Docker attestation artifacts.
type: number
default: 90
docker-image-upload-attestations:
description: Whether to upload attestation files for Docker builds as artifacts.
type: boolean
default: false
docker-image-push:
description: Whether to push Docker images to the registry after building.
type: boolean
default: true
docker-image-registry:
description: The Docker image registry. Use caution when setting a non-default value.
type: string
default: ghcr.io
docker-image-tag-latest:
description: Tags image builds with `latest`.
type: boolean
default: false
docker-image-tag-production:
description: Tags image builds with `production`.
type: boolean
required: false
docker-image-tag-pr:
description: A PR number to add as a Docker image tag (as `pr-<value>`) when building for a pull request.
type: string
required: false
docker-image-tag-release:
description: A tag value that, if provided, signifies the release version associated with the Docker image.
type: string
required: false
docker-image-version:
description: Value to set for the `org.opencontainers.image.version label`.
type: string
default: ""
python-function-artifact-retention-days:
description: Number of days to retain Python function build artifacts.
type: number
default: 90
web-artifact-retention-days:
description: Number of days to retain website build artifacts.
type: number
default: 90
web-dotenv:
description: Contents to write to .env before building website artifacts.
type: string
default: ""
outputs:
build-api-image-result:
value: ${{ jobs.api-docker-image.result }}
build-api-functions-result:
value: ${{ jobs.api-function-zips.result }}
build-console-image-result:
value: ${{ jobs.redwood-console-image.result }}
build-python-functions-result:
value: ${{ jobs.python-function-zips.result }}
build-web-result:
value: ${{ jobs.web-bundle.result }}
api-image-digest:
value: ${{ jobs.api-docker-image.outputs.digest }}
api-image-full-name:
value: ${{ jobs.api-docker-image.outputs.full-name }}
api-attestation-artifacts-key:
value: ${{ jobs.api-docker-image.outputs.attestation-artifacts-key }}
api-attestation-artifacts-path:
value: ${{ jobs.api-docker-image.outputs.attestation-artifacts-path }}
api-functions-artifacts-key:
value: ${{ jobs.api-function-zips.outputs.artifacts-key }}
api-functions-artifacts-path:
value: ${{ jobs.api-function-zips.outputs.artifacts-path }}
api-functions-checksums-sha256:
value: ${{ jobs.api-function-zips.outputs.checksums-sha256 }}
console-image-digest:
value: ${{ jobs.redwood-console-image.outputs.digest }}
console-image-full-name:
value: ${{ jobs.redwood-console-image.outputs.full-name }}
console-attestation-artifacts-key:
value: ${{ jobs.redwood-console-image.outputs.attestation-artifacts-key }}
console-attestation-artifacts-path:
value: ${{ jobs.redwood-console-image.outputs.attestation-artifacts-path }}
python-functions-artifacts-key:
value: ${{ jobs.python-function-zips.outputs.artifacts-key }}
python-functions-artifacts-path:
value: ${{ jobs.python-function-zips.outputs.artifacts-path }}
python-functions-checksums-sha256:
value: ${{ jobs.python-function-zips.outputs.checksums-sha256 }}
web-artifacts-key:
value: ${{ jobs.web-bundle.outputs.artifacts-key }}
web-artifacts-path:
value: ${{ jobs.web-bundle.outputs.artifacts-path }}
web-checksums-sha256:
value: ${{ jobs.web-bundle.outputs.checksums-sha256 }}
jobs:
api-docker-image:
name: Build API Docker image
if: inputs.build-api-image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
env:
ATTESTATION_ARTIFACTS_KEY: "api-image-attestations-${{ inputs.ref }}"
outputs:
commit-tag: ${{ inputs.ref }}
digest: ${{ steps.build-push.outputs.digest }}
full-name: ${{ inputs.docker-image-registry }}/${{ inputs.api-image-name }}@${{ steps.build-push.outputs.digest }}
attestation-artifacts-key: ${{ env.ATTESTATION_ARTIFACTS_KEY }}
attestation-artifacts-path: ${{ steps.store-attestations.outputs.path }}
steps:
- uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
disable-sudo: true
egress-policy: audit
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
id: checkout
with:
ref: ${{ inputs.ref }}
show-progress: 'false'
persist-credentials: 'false'
- name: Set build info for the checked-out commit
id: commit-sha
run: echo "long=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0
with:
platforms: linux/amd64,linux/arm64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3.8.0
with:
platforms: linux/amd64,linux/arm64
- name: Authenticate docker
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # v5.6.1
with:
images: ${{ inputs.docker-image-registry }}/${{ inputs.api-image-name }}
tags: |
type=raw,enable=true,priority=100,prefix=sha-,value=${{ steps.commit-sha.outputs.long }}
type=raw,enable=${{ inputs.docker-image-tag-release != '' }},priority=200,value=${{ inputs.docker-image-tag-release }}
type=raw,enable=${{ inputs.docker-image-tag-latest }},priority=300,value=latest
type=raw,enable=${{ inputs.docker-image-tag-pr != '' }},priority=600,prefix=pr-,value=${{ inputs.docker-image-tag-pr }}
labels: |
org.opencontainers.image.title=${{ inputs.api-image-name }}
org.opencontainers.image.version=${{ inputs.docker-image-version }}
org.opencontainers.image.revision=${{ steps.commit-sha.outputs.long }}
com.datadoghq.tags.service=cpf-reporter
com.datadoghq.tags.version=${{ steps.commit-sha.outputs.long }}
- name: Set bake file definition as step output
id: bakefile
run: |
BAKEFILE_CONTENTS="$(cat $BAKEFILE_PATH)"
echo "result<<ENDOFBAKEFILE" >> $GITHUB_OUTPUT
echo "$BAKEFILE_CONTENTS" >> $GITHUB_OUTPUT
echo "ENDOFBAKEFILE" >> $GITHUB_OUTPUT
env:
BAKEFILE_PATH: ${{ steps.meta.outputs.bake-file }}
- name: Build and push Docker image
id: build-push
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 # v6.10.0
with:
context: .
github-token: ${{ secrets.GITHUB_TOKEN }}
push: ${{ inputs.docker-image-push }}
file: Dockerfile
target: api_serve
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
pull: true
provenance: true
sbom: true
build-args: |
GIT_COMMIT=${{ inputs.ref }}
GIT_REF=${{ inputs.docker-image-args-ref }}
TIMESTAMP=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}
- name: Publish build results
run: |
REPORT_FILE=$(mktemp -t summary.md.XXXXX)
cat >> $REPORT_FILE << 'ENDOFREPORT'
## Docker Build Summary
**Image ID:** `${{ steps.build-push.outputs.imageid }}`
**Image Digest:** `${{ steps.build-push.outputs.digest }}`
<details>
<summary>Bake File</summary>
```json
${{ steps.bakefile.outputs.result }}
```
</details>
<details>
<summary>Build Metadata</summary>
```json
${{ steps.build-push.outputs.metadata }}
```
</details>
ENDOFREPORT
cat "$REPORT_FILE" >> $GITHUB_STEP_SUMMARY
- name: Store attestations
id: store-attestations
if: inputs.docker-image-upload-attestations
run: |
ATTESTATIONS_DIR=$(mktemp -d)
echo "path=$ATTESTATIONS_DIR" >> $GITHUB_OUTPUT
docker buildx imagetools inspect "$INSPECT_NAME" --format "{{ json .SBOM }}" > $ATTESTATIONS_DIR/sbom.sdpx.json
docker buildx imagetools inspect "$INSPECT_NAME" --format "{{ json .Provenance }}" > $ATTESTATIONS_DIR/provenance.json
env:
INSPECT_NAME: ${{ inputs.docker-image-registry }}/${{ inputs.api-image-name }}@${{ steps.build-push.outputs.digest }}
- name: Upload attestations
if: steps.store-attestations.outcome == 'success'
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: ${{ env.ATTESTATION_ARTIFACTS_KEY }}
path: ${{ steps.store-attestations.outputs.path }}
if-no-files-found: error
include-hidden-files: true
retention-days: ${{ inputs.docker-image-artifacts-retention-days }}
redwood-console-image:
name: Build RedwoodJS console Docker image
if: inputs.build-console-image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
env:
ATTESTATION_ARTIFACTS_KEY: "console-image-attestations-${{ inputs.ref }}"
outputs:
commit-tag: ${{ inputs.ref }}
digest: ${{ steps.build-push.outputs.digest }}
full-name: ${{ inputs.docker-image-registry }}/${{ inputs.console-image-name }}@${{ steps.build-push.outputs.digest }}
attestation-artifacts-key: ${{ env.ATTESTATION_ARTIFACTS_KEY }}
attestation-artifacts-path: ${{ steps.store-attestations.outputs.path }}
steps:
- uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
disable-sudo: true
egress-policy: audit
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
id: checkout
with:
ref: ${{ inputs.ref }}
show-progress: 'false'
persist-credentials: 'false'
- name: Set build info for the checked-out commit
id: commit-sha
run: echo "long=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0
with:
platforms: linux/amd64,linux/arm64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3.8.0
with:
platforms: linux/amd64,linux/arm64
- name: Authenticate docker
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # v5.6.1
with:
images: ${{ inputs.docker-image-registry }}/${{ inputs.console-image-name }}
tags: |
type=raw,enable=true,priority=100,prefix=sha-,value=${{ steps.commit-sha.outputs.long }}
type=raw,enable=${{ inputs.docker-image-tag-release != '' }},priority=200,value=${{ inputs.docker-image-tag-release }}
type=raw,enable=${{ inputs.docker-image-tag-latest }},priority=300,value=latest
type=raw,enable=${{ inputs.docker-image-tag-pr != '' }},priority=600,prefix=pr-,value=${{ inputs.docker-image-tag-pr }}
labels: |
org.opencontainers.image.title=${{ inputs.console-image-name }}
org.opencontainers.image.version=${{ inputs.docker-image-version }}
org.opencontainers.image.revision=${{ steps.commit-sha.outputs.long }}
- name: Set bake file definition as step output
id: bakefile
run: |
BAKEFILE_CONTENTS="$(cat $BAKEFILE_PATH)"
echo "result<<ENDOFBAKEFILE" >> $GITHUB_OUTPUT
echo "$BAKEFILE_CONTENTS" >> $GITHUB_OUTPUT
echo "ENDOFBAKEFILE" >> $GITHUB_OUTPUT
env:
BAKEFILE_PATH: ${{ steps.meta.outputs.bake-file }}
- name: Build and push Docker image
id: build-push
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 # v6.10.0
with:
context: .
github-token: ${{ secrets.GITHUB_TOKEN }}
push: ${{ inputs.docker-image-push }}
file: Dockerfile
target: console
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
pull: true
provenance: true
sbom: true
build-args: |
GIT_COMMIT=${{ inputs.ref }}
GIT_REF=${{ inputs.docker-image-args-ref }}
TIMESTAMP=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}
- name: Publish build results
run: |
REPORT_FILE=$(mktemp -t summary.md.XXXXX)
cat >> $REPORT_FILE << 'ENDOFREPORT'
## Docker Build Summary
**Image ID:** `${{ steps.build-push.outputs.imageid }}`
**Image Digest:** `${{ steps.build-push.outputs.digest }}`
<details>
<summary>Bake File</summary>
```json
${{ steps.bakefile.outputs.result }}
```
</details>
<details>
<summary>Build Metadata</summary>
```json
${{ steps.build-push.outputs.metadata }}
```
</details>
ENDOFREPORT
cat "$REPORT_FILE" >> $GITHUB_STEP_SUMMARY
- name: Store attestations
id: store-attestations
if: inputs.docker-image-upload-attestations
run: |
ATTESTATIONS_DIR=$(mktemp -d)
echo "path=$ATTESTATIONS_DIR" >> $GITHUB_OUTPUT
docker buildx imagetools inspect "$INSPECT_NAME" --format "{{ json .SBOM }}" > $ATTESTATIONS_DIR/sbom.sdpx.json
docker buildx imagetools inspect "$INSPECT_NAME" --format "{{ json .Provenance }}" > $ATTESTATIONS_DIR/provenance.json
env:
INSPECT_NAME: ${{ inputs.docker-image-registry }}/${{ inputs.console-image-name }}@${{ steps.build-push.outputs.digest }}
- name: Upload attestations
if: steps.store-attestations.outcome == 'success'
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: ${{ env.ATTESTATION_ARTIFACTS_KEY }}
path: ${{ steps.store-attestations.outputs.path }}
if-no-files-found: error
include-hidden-files: true
retention-days: ${{ inputs.docker-image-artifacts-retention-days }}
api-function-zips:
name: Build API Lambda function zip artifacts
if: inputs.build-api-functions
runs-on: ubuntu-latest
permissions:
contents: read
packages: none
env:
ARTIFACTS_KEY: api-${{ inputs.ref }}
BUILD_OUTPUT_PATH: ${{ github.workspace }}/api/dist
ARTIFACTS_PATH: ${{ github.workspace }}/api/dist/zipballs
outputs:
artifacts-key: ${{ env.ARTIFACTS_KEY }}
artifacts-path: ${{ env.ARTIFACTS_PATH }}
checksums-sha256: ${{ steps.checksums.outputs.sha256 }}
steps:
- uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
disable-sudo: true
egress-policy: audit
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ inputs.ref }}
show-progress: 'false'
persist-credentials: 'false'
- name: Setup Node
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version-file: .nvmrc
cache: yarn
- name: Install dependencies
run: yarn install --immutable
- name: Build the api side
run: yarn rw build api
env:
CI: 1
- name: Zip the built functions
run: yarn zip-it-and-ship-it $BUILD_OUTPUT_PATH/functions $ARTIFACTS_PATH
- name: Add RDS CA bundle to zipped Lambda artifacts
run: |
for zipfile in $ARTIFACTS_PATH/*.zip; do
zip -ju $zipfile api/db/rds-global-bundle.pem
done;
- name: Compute build artifact checksums
id: checksums
run: |
DIST_CHECKSUMS=$(find "$BUILD_OUTPUT_PATH" -type f -exec sha256sum {} \;)
echo "sha256<<EOF" >> $GITHUB_OUTPUT
echo "$DIST_CHECKSUMS" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Publish build results
run: |
REPORT_FILE=$(mktemp -t summary.md.XXXXX)
cat >> $REPORT_FILE << 'ENDOFREPORT'
## Build JS API Functions Summary
<details>
<summary>Checksums</summary>
```
${{ steps.checksums.outputs.sha256 }}
```
</details>
ENDOFREPORT
cat "$REPORT_FILE" >> $GITHUB_STEP_SUMMARY
- name: Upload build artifact
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: ${{ env.ARTIFACTS_KEY }}
path: ${{ env.ARTIFACTS_PATH }}
if-no-files-found: error
include-hidden-files: true
retention-days: ${{ inputs.api-function-artifact-retention-days }}
python-function-zips:
name: Build Python Lambda function zip artifacts
if: inputs.build-python-functions
runs-on: ubuntu-latest
permissions:
contents: read
packages: none
env:
ARTIFACTS_KEY: python-${{ inputs.ref }}
ARTIFACTS_PATH: ${{ github.workspace }}/python/dist/zipballs
outputs:
artifacts-key: ${{ env.ARTIFACTS_KEY }}
artifacts-path: ${{ env.ARTIFACTS_PATH }}
checksums-sha256: ${{ steps.checksums.outcome.sha256 }}
steps:
- uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
disable-sudo: true
egress-policy: audit
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ inputs.ref }}
show-progress: 'false'
persist-credentials: 'false'
- name: Install Poetry
run: pipx install poetry
- name: Setup Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version-file: 'python/pyproject.toml'
cache: poetry
- name: Install dependencies
working-directory: python
run: |
poetry install --only main --sync --no-interaction --no-ansi
echo "INSTALLED_PACKAGE_DIR=$(poetry env info --path --no-interaction --no-ansi)/lib/python3.12/site-packages" >> $GITHUB_ENV
env:
POETRY_VIRTUALENVS_OPTIONS_ALWAYS_COPY: "true"
POETRY_VIRTUALENVS_OPTIONS_NO_PIP: "true"
POETRY_VIRTUALENVS_OPTIONS_NO_SETUPTOOLS: "true"
- name: Clean Python bytecode
run: find python/src $INSTALLED_PACKAGE_DIR | grep -E "(/__pycache__$|\.pyc$|\.pyo$)" | xargs rm -rf
- name: Create build artifact directory
run: mkdir -p $ARTIFACTS_PATH
- name: Zip third-party packages
run: |
pushd $INSTALLED_PACKAGE_DIR
zip -r $ARTIFACTS_PATH/lambda.zip .
popd
- name: Zip Python source code in repo
run: |
pushd python
zip -r $ARTIFACTS_PATH/lambda.zip src
popd
- name: Compute build artifact checksums
id: checksums
run: |
DIST_CHECKSUMS=$(find "$ARTIFACTS_PATH" -type f -exec sha256sum {} \;)
echo "sha256<<EOF" >> $GITHUB_OUTPUT
echo "$DIST_CHECKSUMS" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Publish build results
run: |
REPORT_FILE=$(mktemp -t summary.md.XXXXX)
cat >> $REPORT_FILE << 'ENDOFREPORT'
## Build Python API Functions Summary
<details>
<summary>Checksums</summary>
```
${{ steps.checksums.outputs.sha256 }}
```
</details>
ENDOFREPORT
cat "$REPORT_FILE" >> $GITHUB_STEP_SUMMARY
- name: Upload build artifact
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: ${{ env.ARTIFACTS_KEY }}
path: ${{ env.ARTIFACTS_PATH }}
if-no-files-found: error
include-hidden-files: true
retention-days: ${{ inputs.python-function-artifact-retention-days }}
web-bundle:
name: Build website deployment artifact
if: inputs.build-web
runs-on: ubuntu-latest
permissions:
contents: read
packages: none
env:
ARTIFACTS_KEY: web-${{ inputs.ref }}
ARTIFACTS_PATH: ${{ github.workspace }}/web/dist
outputs:
artifacts-key: ${{ env.ARTIFACTS_KEY }}
artifacts-path: ${{ env.ARTIFACTS_PATH }}
checksums-sha256: ${{ steps.checksums.outputs.sha256 }}
steps:
- uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
disable-sudo: true
egress-policy: audit
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ inputs.ref }}
show-progress: 'false'
persist-credentials: 'false'
- name: Setup Node
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version-file: .nvmrc
cache: yarn
cache-dependency-path: yarn.lock
- name: Install dependencies
run: yarn install --immutable
- name: Write env vars for build
run: cat <<< "$DOTENV_FOR_BUILD" >> .env
env:
DOTENV_FOR_BUILD: ${{ inputs.web-dotenv }}
- name: Build the website
run: yarn rw build web
env:
CI: 1
- name: Compute build artifact checksums
id: checksums
run: |
DIST_CHECKSUMS=$(find "$ARTIFACTS_PATH" -type f -exec sha256sum {} \;)
echo "sha256<<EOF" >> $GITHUB_OUTPUT
echo "$DIST_CHECKSUMS" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Publish build results
run: |
REPORT_FILE=$(mktemp -t summary.md.XXXXX)
cat >> $REPORT_FILE << 'ENDOFREPORT'
## Build Website Summary
<details>
<summary>Checksums</summary>
```
${{ steps.checksums.outputs.sha256 }}
```
</details>
ENDOFREPORT
cat "$REPORT_FILE" >> $GITHUB_STEP_SUMMARY
- name: Upload build artifact
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: ${{ env.ARTIFACTS_KEY }}
path: ${{ env.ARTIFACTS_PATH }}
if-no-files-found: error
include-hidden-files: true
retention-days: ${{ inputs.web-artifact-retention-days }}