Skip to content
Permalink
ab7c5072d6
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
executable file 38 lines (31 sloc) 1.36 KB
#!/usr/bin/env bash
echo "[INFO] $0 started at `date`"
# Read the commit hash
read -r commit_hash<<<$(git rev-parse --short HEAD)
echo "[INFO] Commit hash: \"$commit_hash\""
image_name=shib-proxy
# Read the version
read -r version<<<$(docker inspect --format='{{.Config.Labels.version}}' $image_name:$commit_hash)
if [[ "$version" == "" ]]; then
echo "[ERROR] Unable to inspect version label for image $image_name:$commit_hash"
exit 1
fi
echo "[INFO] Version: \"$version\""
read -r major minor patch<<<$(echo $version | tr . ' ')
echo "[DEBUG] major.minor.patch=\"$major.$minor.$patch\""
# Tag the image
echo "[INFO] Tagging the container image"
docker tag $image_name:$commit_hash ${ECR_HOSTNAME}/${image_name}:$major.$minor.$patch
docker tag $image_name:$commit_hash ${ECR_HOSTNAME}/${image_name}:$major.$minor
docker tag $image_name:$commit_hash ${ECR_HOSTNAME}/${image_name}:$major
# Push the image to a registry if REPOSITORY_BASE is defined
if [ -z "$ECR_HOSTNAME" ]; then
echo "[ERROR] Unable to push image (ECR_HOSTNAME not specified)"
else
echo "[DEBUG] ECR_HOSTNAME=\"$ECR_HOSTNAME\""
docker push ${ECR_HOSTNAME}/${image_name}:latest
docker push ${ECR_HOSTNAME}/${image_name}:$major.$minor.$patch
docker push ${ECR_HOSTNAME}/${image_name}:$major.$minor
docker push ${ECR_HOSTNAME}/${image_name}:$major
fi
echo "[INFO] $0 finished at `date`"