From 1fd302b0dfd785606d715a0deb9671ab5345e297 Mon Sep 17 00:00:00 2001 From: Sam Seed Date: Tue, 10 Oct 2023 10:20:20 +0100 Subject: [PATCH] CLDC-2563: don't push image if tag already exists --- .github/workflows/aws_deploy.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/aws_deploy.yml b/.github/workflows/aws_deploy.yml index e7e473841..eabff2f04 100644 --- a/.github/workflows/aws_deploy.yml +++ b/.github/workflows/aws_deploy.yml @@ -49,8 +49,13 @@ jobs: with: mask-password: 'true' + - name: Check if image with tag already exists + run: | + echo "image-exists=$(if aws ecr list-images --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 == 'false' }} env: registry: ${{ steps.ecr-login.outputs.registry }} commit_tag: ${{ github.sha }} @@ -63,9 +68,6 @@ jobs: runs-on: ubuntu-latest environment: ${{ inputs.environment }} needs: push_docker_image - if: | - always() && - (needs.push_docker_image.result == 'success' || needs.push_docker_image.result == 'skipped') steps: - name: Configure AWS credentials