Skip to content

Commit 46cc7aa

Browse files
dvvanessastoiberdvviktordelevpuehringer
authored
Add retry loop for image scan (#117)
* add debug to image scan * adapt workflow_branch * adapt workflow_branch * fix remaining branch references * add retry loop for image-scan * revert branches * Update .github/actions/get-ecr-scan-result/action.yml Co-authored-by: Michael Pühringer <[email protected]> * Update .github/actions/get-ecr-scan-result/action.yml --------- Co-authored-by: Viktor Delev <[email protected]> Co-authored-by: Michael Pühringer <[email protected]>
1 parent d8089a8 commit 46cc7aa

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

.github/actions/get-ecr-scan-result/action.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,18 @@ runs:
5353
- name: Get AWS ECR Scan results
5454
id: get-scan-results
5555
run: |
56-
aws ecr wait image-scan-complete --repository-name $ECR_REPOSITORY --image-id imageTag=$IMAGE_TAG
57-
if [ $(echo $?) -eq 0 ]; then
56+
# As the image scan itself may not be started yet, we have to wait (and retry) until it is actually available
57+
max_retries=5
58+
retries=0
59+
scan_complete=1
60+
until [ $retries -eq $max_retries ]; do
61+
aws ecr wait image-scan-complete --repository-name $ECR_REPOSITORY --image-id imageTag=$IMAGE_TAG && scan_complete=0 && break
62+
sleep 5
63+
retries=$((retries + 1))
64+
echo "Retry $retries/$max_retries: Waiting for image scan to start..."
65+
done
66+
67+
if [ $scan_complete -eq 0 ]; then
5868
scan_findings=$(aws ecr describe-image-scan-findings --repository-name $ECR_REPOSITORY --image-id imageTag=$IMAGE_TAG | jq '.imageScanFindings.findingSeverityCounts')
5969
critical=$(echo $scan_findings | jq '.CRITICAL')
6070
high=$(echo $scan_findings | jq '.HIGH')

0 commit comments

Comments
 (0)