forked from microservices-demo/microservices-demo
-
Notifications
You must be signed in to change notification settings - Fork 9
/
push.sh
executable file
·46 lines (40 loc) · 1.49 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
#!/usr/bin/env bash
if [ "$TRAVIS_EVENT_TYPE" == "cron" ]; then
echo "Not pushing artifacts in cron jobs";
exit 0;
fi;
if [ -z "$DOCKER_PASS" ] ; then
echo "This is a build triggered by an external PR. Skipping docker push.";
exit 0;
fi;
docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS
for svc in openapi healthcheck; do
export REPO=${GROUP}/$(basename $svc);
echo "Building ${REPO}:$TRAVIS_COMMIT";
docker build -t ${REPO}:$TRAVIS_COMMIT ./$svc; DOCKER_EXIT=$(echo $?); if [[ "$DOCKER_EXIT" > 0 ]] ; then
echo "Docker build failed with exit code $DOCKER_EXIT";
exit 1;
fi;
export DOCKER_PUSH=1;
while [ "$DOCKER_PUSH" -gt 0 ] ; do
echo "Pushing $REPO:$TRAVIS_COMMIT";
docker push $REPO:$TRAVIS_COMMIT;
DOCKER_PUSH=$(echo $?);
if [[ "$DOCKER_PUSH" -gt 0 ]] ; then
echo "Docker push failed with exit code $DOCKER_PUSH";
fi;
done;
if [ "$TRAVIS_BRANCH" == "master" ]; then
docker tag $REPO:$TRAVIS_COMMIT $REPO:snapshot;
echo "Pushing $REPO:snapshot";
docker push $REPO:snapshot;
fi;
if [ ! -z "$TRAVIS_TAG" ];
then docker tag $REPO:$TRAVIS_COMMIT $REPO:$TRAVIS_TAG;
docker push $REPO:$TRAVIS_TAG;
docker tag $REPO:$TRAVIS_COMMIT $REPO:latest;
docker push $REPO:latest;
fi;
done
mkdir cfn-to-publish
jq ".Description += \" (microservices-demo/microservices-demo@${TRAVIS_COMMIT})\"" "deploy/aws-ecs/cloudformation.json" > cfn-to-publish/microservices-demo.json