Skip to content

Instantly share code, notes, and snippets.

@waltervargas
Created June 13, 2017 01:24
Show Gist options
  • Save waltervargas/46e312c3809805409acda5596b9341b8 to your computer and use it in GitHub Desktop.
Save waltervargas/46e312c3809805409acda5596b9341b8 to your computer and use it in GitHub Desktop.
Checks if the last commit hash is present as a tag for Docker Images in a particular ECR repository.
NAME=dockercoins
IMAGES=$(aws --region ${REGION} ecr list-images --repository-name ${NAME} --output json)
COMMIT_ID=$(git log --pretty=format:%H -1 . )
IMAGES_TEST_COMMIT_ID=$(echo $IMAGES | jq '.imageIds[] | .imageTag | select (.!=null) | test("$COMMIT_ID")')
if [[ ! ${IMAGES_TEST_COMMIT_ID} == *true* ]]; then
echo "Build and Push to ECR"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment