forked from HSLdevcom/digitransit-proxy
-
Notifications
You must be signed in to change notification settings - Fork 1
/
travis-build.sh
executable file
·38 lines (33 loc) · 1007 Bytes
/
travis-build.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
#!/bin/bash
# Set these environment variables
#DOCKER_TAG=
#DOCKER_USER=
#DOCKER_AUTH=
set -o errexit -o nounset -o xtrace
ORG=${ORG:-hsldevcom}
DOCKER_TAG=${TRAVIS_COMMIT:-latest}
DOCKER_IMAGE=$ORG/digitransit-proxy:$DOCKER_TAG
LATEST_IMAGE=$ORG/digitransit-proxy:latest
PROD_IMAGE=$ORG/digitransit-proxy:prod
if [ "${TRAVIS_PULL_REQUEST}" == "false" ]; then
docker login -u ${DOCKER_USER} -p ${DOCKER_AUTH}
if [ "$TRAVIS_TAG" ];then
echo "processing release $TRAVIS_TAG"
#release do not rebuild, just tag
docker pull $DOCKER_IMAGE
docker tag ${DOCKER_IMAGE} ${PROD_IMAGE}
docker push ${PROD_IMAGE}
else
echo "processing master build $TRAVIS_COMMIT"
./test.sh
docker build --tag=$DOCKER_IMAGE -f Dockerfile .
docker push ${DOCKER_IMAGE}
docker tag ${DOCKER_IMAGE} ${LATEST_IMAGE}
docker push ${LATEST_IMAGE}
fi
else
echo "processing pr $TRAVIS_PULL_REQUEST"
./test.sh
docker build --tag=$DOCKER_IMAGE -f Dockerfile .
fi
echo Build completed