From d2b0caa8384aedf8805cc622e0b2094ad8cb9aad Mon Sep 17 00:00:00 2001 From: Silas Sewell Date: Wed, 4 Nov 2015 16:24:46 -0500 Subject: [PATCH] Update build.sh to work with GIT_HEAD --- build.sh | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index c53d60562..0ddeaf1fd 100755 --- a/build.sh +++ b/build.sh @@ -1,4 +1,23 @@ -TAG=$(git rev-parse --short HEAD)$(test -n "$(git status --porcelain)" && echo -dirty) -REPO=quay.io/quay/quay:$TAG +#!/usr/bin/env bash + +set -e + +if [[ -n "$(git status --porcelain)" ]]; then + echo 'dirty build not supported' >&2 + exit 1 +fi + +# get named head (ex: branch, tag, etc..) +NAME="$( git rev-parse --abbrev-ref HEAD )" + +# get 7-character sha +SHA=$( git rev-parse --short HEAD ) + +# checkout commit so .git/HEAD points to full sha (used in Dockerfile) +git checkout $SHA + +REPO=quay.io/quay/quay:$SHA docker build -t $REPO . echo $REPO + +git checkout "$NAME"