Skip to content

Commit 10f4e56

Browse files
committed
Fix wc error when file doesn't exist
1 parent 5a085af commit 10f4e56

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ jobs:
271271
if: ${{ !cancelled() }}
272272

273273
- name: Fail if any images have critical vulnerabilities
274-
run: if [ $(wc -l < image-build-logs/image-scan-output/critical-images.txt) -gt 0 ]; then exit 1; fi
274+
run: if [ -e image-build-logs/image-scan-output/critical-images.txt ] && [ $(wc -l < image-build-logs/image-scan-output/critical-images.txt) -gt 0 ]; then exit 1; fi
275275
if: ${{ !inputs.push-critical }}
276276

277277
- name: Copy clean images to push-attempt-images list
@@ -330,7 +330,7 @@ jobs:
330330
if: ${{ steps.build_overcloud_images.outcome == 'failure' || steps.build_seed_images.outcome == 'failure' }}
331331

332332
- name: Fail when images failed to push
333-
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
333+
run: if [ -e image-build-logs/push-failed-images.txt ] && [ $(wc -l < image-build-logs/push-failed-images.txt) -gt 0 ]; then cat image-build-logs/push-failed-images.txt && exit 1; fi
334334
if: ${{ inputs.push && !cancelled() }}
335335

336336
# NOTE(seunghun1ee): Currently we want to mark the job fail only when critical CVEs are detected.
@@ -341,7 +341,7 @@ jobs:
341341
# if: ${{ !inputs.push-critical && !cancelled() }}
342342

343343
- name: Fail when critical vulnerabilities are found
344-
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
344+
run: if [ -e image-build-logs/image-scan-output/critical-images.txt ] && [ $(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
345345
if: ${{ !inputs.push-critical && !cancelled() }}
346346

347347
- name: Remove locally built images for this run

0 commit comments

Comments
 (0)