From 538485da4da7a5ee2c8c15f5d67048082a4aad02 Mon Sep 17 00:00:00 2001 From: Sam Seed Date: Mon, 9 Oct 2023 16:44:49 +0100 Subject: [PATCH] Check for image existence using aws ecr list-images --- .github/workflows/aws_deploy.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/aws_deploy.yml b/.github/workflows/aws_deploy.yml index f8005d9e8..0ca309c5e 100644 --- a/.github/workflows/aws_deploy.yml +++ b/.github/workflows/aws_deploy.yml @@ -49,16 +49,14 @@ jobs: with: mask-password: 'true' - - name: Check if image with tag already exists (hide errors?) - run: | - aws ecr describe-images --repository-name=$repository --image-ids=imageTag=${{ github.sha }} 2> /dev/null - - name: Check if image with tag already exists + id: check-image-exists run: | - aws ecr describe-images --repository-name=$repository --image-ids=imageTag=${{ github.sha }} + echo "image-exists=$(if aws ecr list-images --no-paginate --repository-name=$repository --query "imageIds[*].imageTag" | grep -q ${{ github.sha }}; then echo true; else echo false; fi)" >> $GITHUB_ENV - name: Build, tag, and push docker image to ECR id: build-image + if: ${{ ! env.image-exists }} env: registry: ${{ steps.ecr-login.outputs.registry }} commit_tag: ${{ github.sha }}