Last active
December 10, 2018 14:35
-
-
Save DaRaFF/25b2dd9c87c924984d59c36f4acb26da to your computer and use it in GitHub Desktop.
Get First Livingdocs Server Docker Image Name
This file contains hidden or 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
#!/bin/bash | |
# ./get-first-livingdocs-server-docker-image-name.sh my-feature release-2018-11 master | |
# returns the first existing image on dockerhub e.g. 'release-2018-11' | |
TOKEN=$( curl -sSLd "username=${DOCKER_USERNAME}&password=${DOCKER_PASSWORD}" https://hub.docker.com/v2/users/login | jq -r ".token" ) | |
for DOCKER_TAG in "$@"; | |
do | |
IMAGE_TAG=$(curl -sH "Authorization: JWT $TOKEN" "https://hub.docker.com/v2/repositories/livingdocs/server/tags/${DOCKER_TAG}/" | jq 'select(.name != null)' | jq .name | cut -f2 -d$'"') | |
if [ ! -z "$IMAGE_TAG" ]; then | |
echo $IMAGE_TAG | |
exit 0 | |
fi | |
done | |
# default | |
echo "master" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment