Skip to content

Commit 97a8999

Browse files
priteauelelaysh
authored andcommitted
backport stackhpc-container-image-build.yml from 2025.1
1 parent 394db65 commit 97a8999

1 file changed

Lines changed: 18 additions & 21 deletions

File tree

.github/workflows/stackhpc-container-image-build.yml

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ on:
3838
type: boolean
3939
required: false
4040
default: true
41-
push-dirty:
41+
sbom:
42+
description: Generate SBOM?
43+
type: boolean
44+
required: false
45+
default: true
46+
push-critical:
4247
description: Push scanned images that have critical vulnerabilities?
4348
type: boolean
4449
required: false
@@ -198,17 +203,6 @@ jobs:
198203
localhost ansible_connection=local ansible_python_interpreter=/usr/bin/python3
199204
EOF
200205
201-
# See etc/kayobe/ansible/roles/pulp_auth_proxy/README.md for details.
202-
# NOTE: We override pulp_auth_proxy_conf_path to a path shared by the
203-
# runner and dind containers.
204-
- name: Deploy an authenticating package repository mirror proxy
205-
run: |
206-
source venvs/kayobe/bin/activate &&
207-
source src/kayobe-config/kayobe-env --environment ci-builder &&
208-
kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/pulp-auth-proxy.yml -e pulp_auth_proxy_conf_path=/home/runner/_work/pulp_proxy
209-
env:
210-
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }}
211-
212206
- name: Create build logs output directory
213207
run: mkdir image-build-logs
214208

@@ -230,6 +224,9 @@ jobs:
230224
args="$args -e stackhpc_repo_mirror_auth_proxy_enabled=true"
231225
args="$args -e kolla_build_log_path=$GITHUB_WORKSPACE/image-build-logs/kolla-build-overcloud.log"
232226
args="$args -e base_path=$GITHUB_WORKSPACE/opt/kayobe"
227+
# NOTE: We override pulp_auth_proxy_conf_path to a path shared by the
228+
# runner and dind containers.
229+
args="$args -e pulp_auth_proxy_conf_path=/home/runner/_work/pulp_proxy"
233230
source venvs/kayobe/bin/activate &&
234231
source src/kayobe-config/kayobe-env --environment ci-builder &&
235232
kayobe overcloud container image build $args
@@ -267,15 +264,15 @@ jobs:
267264
run: if [ $(wc -l < ${{ matrix.distro.name }}-${{ matrix.distro.release }}-container-images) -le 1 ]; then exit 1; fi
268265

269266
- name: Scan built container images
270-
run: src/kayobe-config/tools/scan-images.sh ${{ matrix.distro.name }}-${{ matrix.distro.release }} ${{ steps.write-kolla-tag.outputs.kolla-tag }}
267+
run: src/kayobe-config/tools/scan-images.sh ${{ matrix.distro.name }}-${{ matrix.distro.release }} ${{ steps.write-kolla-tag.outputs.kolla-tag }} ${{ inputs.sbom && '--sbom' }}
271268

272269
- name: Move image scan logs to output artifact
273270
run: mv image-scan-output image-build-logs/image-scan-output
274271
if: ${{ !cancelled() }}
275272

276-
- name: Fail if no images have passed scanning
273+
- name: Fail if any images have critical vulnerabilities
277274
run: if [ $(wc -l < image-build-logs/image-scan-output/critical-images.txt) -gt 0 ]; then exit 1; fi
278-
if: ${{ !inputs.push-dirty }}
275+
if: ${{ !inputs.push-critical }}
279276

280277
- name: Copy clean images to push-attempt-images list
281278
run: cp image-build-logs/image-scan-output/clean-images.txt image-build-logs/push-attempt-images.txt
@@ -285,13 +282,13 @@ jobs:
285282
# This should be reverted when it's decided to filter high level CVEs as well.
286283
- name: Append dirty images to push list
287284
run: |
288-
cat image-build-logs/image-scan-output/dirty-images.txt >> image-build-logs/push-attempt-images.txt
285+
cat image-build-logs/image-scan-output/high-images.txt >> image-build-logs/push-attempt-images.txt
289286
if: ${{ inputs.push }}
290287

291288
- name: Append images with critical vulnerabilities to push list
292289
run: |
293290
cat image-build-logs/image-scan-output/critical-images.txt >> image-build-logs/push-attempt-images.txt
294-
if: ${{ inputs.push && inputs.push-dirty }}
291+
if: ${{ inputs.push && inputs.push-critical }}
295292

296293
- name: Push images
297294
run: |
@@ -334,18 +331,18 @@ jobs:
334331

335332
- name: Fail when images failed to push
336333
run: if [ $(wc -l < image-build-logs/push-failed-images.txt) -gt 0 ]; then cat image-build-logs/push-failed-images.txt && exit 1; fi
337-
if: ${{ !cancelled() }}
334+
if: ${{ inputs.push && !cancelled() }}
338335

339336
# NOTE(seunghun1ee): Currently we want to mark the job fail only when critical CVEs are detected.
340337
# This can be used again instead of "Fail when critical vulnerabilities are found" when it's
341338
# decided to fail the job on detecting high CVEs as well.
342339
# - name: Fail when images failed scanning
343-
# run: if [ $(wc -l < image-build-logs/image-scan-output/dirty-images.txt) -gt 0 ]; then cat image-build-logs/image-scan-output/dirty-images.txt && exit 1; fi
344-
# if: ${{ !inputs.push-dirty && !cancelled() }}
340+
# run: if [ $(wc -l < image-build-logs/image-scan-output/high-images.txt) -gt 0 ]; then cat image-build-logs/image-scan-output/high-images.txt && exit 1; fi
341+
# if: ${{ !inputs.push-critical && !cancelled() }}
345342

346343
- name: Fail when critical vulnerabilities are found
347344
run: if [ $(wc -l < image-build-logs/image-scan-output/critical-images.txt) -gt 0 ]; then cat image-build-logs/image-scan-output/critical-images.txt && exit 1; fi
348-
if: ${{ !inputs.push-dirty && !cancelled() }}
345+
if: ${{ !inputs.push-critical && !cancelled() }}
349346

350347
- name: Remove locally built images for this run
351348
if: always() && runner.arch == 'ARM64'

0 commit comments

Comments
 (0)