Update ECR repository creation to enable image scanning on push

This commit is contained in:
Sailinder 2026-08-12 12:24:02 +02:00
parent 846a7e68a6
commit d2e3642a54
No known key found for this signature in database
GPG Key ID: 1CBD752C60D8B536
1 changed files with 57 additions and 55 deletions

View File

@ -29,12 +29,14 @@ jobs:
- name: Login to Amazon ECR - name: Login to Amazon ECR
id: login-ecr id: login-ecr
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 # v2.0.1 uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 # v2.0.1
- name: Create ECR repository (if it does not exist)
aws ecr create-repository \ run: |
aws ecr create-repository \
--repository-name "${ECR_REPOSITORY}" \ --repository-name "${ECR_REPOSITORY}" \
--image-scanning-configuration scanOnPush=true \ --image-scanning-configuration scanOnPush=false \
>/dev/null 2>&1 || aws ecr describe-repositories --repository-names "${ECR_REPOSITORY}" >/dev/null >/dev/null 2>&1 || aws ecr describe-repositories --repository-names "${ECR_REPOSITORY}" >/dev/null
- name: Enforce image tag immutability - name: Enforce image tag immutability
run: | run: |
aws ecr put-image-tag-mutability \ aws ecr put-image-tag-mutability \
@ -52,4 +54,4 @@ aws ecr create-repository \
with: with:
context: ${{ github.workspace }} context: ${{ github.workspace }}
push: true push: true
tags: ${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }}:${{ github.event.release.tag_name }} tags: ${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }}:${{ github.event.release.tag_name }}