Permalink
Cannot retrieve contributors at this time
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?
docker-shib-proxy/ci/deploy.sh
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
executable file
38 lines (31 sloc)
1.36 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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`" |