#!/usr/bin/env sh

if [ "$DOCKER_TAG" = "latest" ]; then
  echo "Building :latest, without VERSION_ARG"
  TAG=`curl -s https://api.github.com/repos/t-neumann/slamdunk/releases | grep tag_name | head -n 1 | cut -d '"' -f 4`
  echo $TAG
  docker build --build-arg VERSION_ARG="$TAG" -t ${IMAGE_NAME} .
else
  echo "Building :$DOCKER_TAG, with VERSION_ARG=\"--vers $DOCKER_TAG\""
  docker build --build-arg VERSION_ARG="$DOCKER_TAG" -t ${IMAGE_NAME} .
fi