Skip to content

Commit

Permalink
add retry loop for image-scan
Browse files Browse the repository at this point in the history
  • Loading branch information
dvviktordelev committed Nov 6, 2024
1 parent 0b7a4cc commit 499a978
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions .github/actions/get-ecr-scan-result/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,17 @@ runs:
- name: Get AWS ECR Scan results
id: get-scan-results
run: |
aws ecr wait image-scan-complete --debug --repository-name $ECR_REPOSITORY --image-id imageTag=$IMAGE_TAG
if [ $(echo $?) -eq 0 ]; then
max_retries=5
retries=0
scan_complete=1
until [ $retries -eq $max_retries ]; do
aws ecr wait image-scan-complete --repository-name $ECR_REPOSITORY --image-id imageTag=$IMAGE_TAG && scan_complete=0 && break
sleep 5
retries=$((retries + 1))
echo "Retry $retries/$max_retries: Waiting for image scan to complete..."
done
if [ $scan_complete -eq 0 ]; then
scan_findings=$(aws ecr describe-image-scan-findings --repository-name $ECR_REPOSITORY --image-id imageTag=$IMAGE_TAG | jq '.imageScanFindings.findingSeverityCounts')
critical=$(echo $scan_findings | jq '.CRITICAL')
high=$(echo $scan_findings | jq '.HIGH')
Expand Down

0 comments on commit 499a978

Please sign in to comment.