Skip to content

Commit 2fd85d0

Browse files
committed
Only provide test_images_report if folder isn't empty
1 parent 19b2d92 commit 2fd85d0

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

.github/workflows/build-docker-artifacts.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ jobs:
118118
build_time: buildTime,
119119
image_tag: imageTag,
120120
image_tag_branch_name: imageTagBranchName,
121-
ecr_respositories: flavor.components.map(component => component.ecr_repository),
121+
ecr_repositories: flavor.components.map(component => component.ecr_repository),
122122
test_images: {
123123
enabled: testImageEnabled,
124124
script_path: testImagesHookScript,
@@ -296,7 +296,7 @@ jobs:
296296
vuln-type: "os,library"
297297
severity: ${{ steps.set_severity.outputs.severity }}
298298
# The cache update takes quite long, so let's try to disable it for now: https://github.com/aquasecurity/trivy-action#cache
299-
cache: 'false'
299+
cache: "false"
300300
continue-on-error: false
301301

302302
- name: Push image
@@ -353,15 +353,17 @@ jobs:
353353
export "IMAGE_${name_upper}=${image_ref}"
354354
done;
355355
356-
# Create report folder to avoid any downstream Docker volume issues
357-
# TODO: For some reason this doesn't work yet, i.e. if a docker-compose script mounts a volume here, nothing shows up...
356+
# Create a directory to store the report results
358357
mkdir -p "$test_images_report"
359-
chmod 777 "$test_images_report"
360-
echo "test_images_report=${test_images_report}" >> "$GITHUB_OUTPUT"
361358
362359
echo "Run $test_images_hook"
363360
chmod +x "$test_images_hook"
364361
bash "$test_images_hook"
362+
363+
# If the report folder is not empty, we store it as output
364+
if [[ -n "$(ls -A "$test_images_report")" ]]; then
365+
echo "test_images_report=${test_images_report}" >> "$GITHUB_OUTPUT"
366+
fi
365367
else
366368
echo "No $test_images_hook found, skipping tests."
367369
fi
@@ -425,7 +427,7 @@ jobs:
425427
echo "image_tag=$image_tag"
426428
echo "image_tag_branch_name=$image_tag_branch_name"
427429
428-
for repository_name in $(jq -r '.ecr_respositories[]' <<< "$FLAVOR"); do
430+
for repository_name in $(jq -r '.ecr_repositories[]' <<< "$FLAVOR"); do
429431
IMAGE_META=$(aws ecr describe-images --repository-name "$repository_name" --image-ids imageTag="$image_tag" --output json | jq --arg var "${image_tag_branch_name}" '.imageDetails[0].imageTags | index( $var )')
430432
if [[ -z "${IMAGE_META}" || ${IMAGE_META} == "null" ]]; then
431433
MANIFEST=$(aws ecr batch-get-image --repository-name "$repository_name" --image-ids imageTag="$image_tag" --output json | jq --raw-output --join-output '.images[0].imageManifest')

0 commit comments

Comments
 (0)