forked from schemaspy/schemaspy
-
Notifications
You must be signed in to change notification settings - Fork 1
/
docker.sh
executable file
·43 lines (38 loc) · 1.09 KB
/
docker.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env bash
# Exit on failure
set -e
REPO=schemaspy/schemaspy
function build() {
echo "Building docker image ${REPO}:${1:-local}"
docker build -t ${REPO}:${1:-local} --build-arg GIT_BRANCH=$TRAVIS_BRANCH --build-arg GIT_REVISION=$TRAVIS_COMMIT .
}
function deploy() {
if [[ "${TRAVIS_PULL_REQUEST}" == "false" ]] &&
[[ -n ${DOCKER_USER} ]] &&
[[ -n ${DOCKER_PASS} ]]; then
docker login -u ${DOCKER_USER} -p ${DOCKER_PASS}
echo "Deploying snapshot"
docker push ${REPO}:snapshot
if [[ ${TRAVIS_TAG} =~ ^v[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then
docker tag ${REPO}:snapshot ${REPO}:${TRAVIS_TAG:1}
echo "Deploying release ${TRAVIS_TAG:1}"
docker push ${REPO}:${TRAVIS_TAG:1}
echo "Deploying latest"
docker tag ${REPO}:${TRAVIS_TAG:1} ${REPO}:latest
docker push ${REPO}:latest
fi
else
echo "Skipping deploy"
fi
}
case "$1" in
build)
build $2
;;
deploy)
deploy
;;
*)
echo "Bad argument: $1"
exit 1
esac