Update build.sh to work with GIT_HEAD
This commit is contained in:
parent
5f49c4da7c
commit
d2b0caa838
1 changed files with 21 additions and 2 deletions
23
build.sh
23
build.sh
|
@ -1,4 +1,23 @@
|
||||||
TAG=$(git rev-parse --short HEAD)$(test -n "$(git status --porcelain)" && echo -dirty)
|
#!/usr/bin/env bash
|
||||||
REPO=quay.io/quay/quay:$TAG
|
|
||||||
|
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 .
|
docker build -t $REPO .
|
||||||
echo $REPO
|
echo $REPO
|
||||||
|
|
||||||
|
git checkout "$NAME"
|
||||||
|
|
Reference in a new issue