forked from microservices-demo/load-test
-
Notifications
You must be signed in to change notification settings - Fork 0
/
push.sh
executable file
·51 lines (44 loc) · 1.09 KB
/
push.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
44
45
46
47
48
49
50
51
#!/usr/bin/env bash
set -ev
if [[ -z "$GROUP" ]] ; then
echo "Cannot find GROUP env var"
exit 1
fi
if [[ -z "$COMMIT" ]] ; then
echo "Cannot find COMMIT env var"
exit 1
fi
push() {
DOCKER_PUSH=1;
while [ $DOCKER_PUSH -gt 0 ] ; do
echo "Pushing $1";
docker push $1;
DOCKER_PUSH=$(echo $?);
if [[ "$DOCKER_PUSH" -gt 0 ]] ; then
echo "Docker push failed with exit code $DOCKER_PUSH";
fi;
done;
}
tag_and_push_all() {
if [[ -z "$1" ]] ; then
echo "Please pass the tag"
exit 1
else
TAG=$1
fi
DOCKER_REPO=${GROUP}/${REPO}
if [[ "$COMMIT" != "$TAG" ]]; then
echo "Tagging docker release"
docker tag ${DOCKER_REPO}:${COMMIT} ${DOCKER_REPO}:${TAG}
fi
push "$DOCKER_REPO:$TAG";
}
# Push snapshot when in master
if [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
tag_and_push_all master-${COMMIT:0:8}
fi;
# Push tag and latest when tagged
if [ -n "$TRAVIS_TAG" ]; then
tag_and_push_all ${TRAVIS_TAG}
tag_and_push_all latest
fi;