Skip to content

Commit 499a978

Browse files
committed
add retry loop for image-scan
1 parent 0b7a4cc commit 499a978

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,17 @@ runs:
5353
- name: Get AWS ECR Scan results
5454
id: get-scan-results
5555
run: |
56-
aws ecr wait image-scan-complete --debug --repository-name $ECR_REPOSITORY --image-id imageTag=$IMAGE_TAG
57-
if [ $(echo $?) -eq 0 ]; then
56+
max_retries=5
57+
retries=0
58+
scan_complete=1
59+
until [ $retries -eq $max_retries ]; do
60+
aws ecr wait image-scan-complete --repository-name $ECR_REPOSITORY --image-id imageTag=$IMAGE_TAG && scan_complete=0 && break
61+
sleep 5
62+
retries=$((retries + 1))
63+
echo "Retry $retries/$max_retries: Waiting for image scan to complete..."
64+
done
65+
66+
if [ $scan_complete -eq 0 ]; then
5867
scan_findings=$(aws ecr describe-image-scan-findings --repository-name $ECR_REPOSITORY --image-id imageTag=$IMAGE_TAG | jq '.imageScanFindings.findingSeverityCounts')
5968
critical=$(echo $scan_findings | jq '.CRITICAL')
6069
high=$(echo $scan_findings | jq '.HIGH')

0 commit comments

Comments
 (0)