Skip to content

Instantly share code, notes, and snippets.

@DaRaFF
Last active December 10, 2018 14:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DaRaFF/25b2dd9c87c924984d59c36f4acb26da to your computer and use it in GitHub Desktop.
Save DaRaFF/25b2dd9c87c924984d59c36f4acb26da to your computer and use it in GitHub Desktop.
Get First Livingdocs Server Docker Image Name
#!/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