-
Notifications
You must be signed in to change notification settings - Fork 41
/
deploy_travisci.sh
38 lines (29 loc) · 1.28 KB
/
deploy_travisci.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/sh
# Builds and deploys JAR build artifact to GitHub (acts as binary repository)
# Builds immutable Docker Image, deploying the JAR, above.
# Uses encrypted environment variables in .travis.yml file used here
# travis encrypt GH_TOKEN=<your_token_hash> --add
# travis encrypt COMMIT_AUTHOR_EMAIL=<your_email_here> --add
# travis encrypt GH_ARTIFACT_REPO=github.com/<your_repo_path>.git --add
# travis encrypt DOCKER_USERNAME=<your_username> --add
# travis encrypt DOCKER_PASSWORD=<your_password> --add
#set -x
SERVICE_NAME=${1:-voter}
BRANCH=${2:-gke}
# Builds and deploys JAR build artifact to GitHub (acts as binary repository)
cd build/libs
git init
git config user.name "travis-ci"
git config user.email "${COMMIT_AUTHOR_EMAIL}"
git add *.jar
git commit -m "Deploy Travis CI Build #${TRAVIS_BUILD_NUMBER} artifacts to GitHub"
git push --force --quiet "https://${GH_TOKEN}@${GH_ARTIFACT_REPO}" master:build-artifacts-${BRANCH}
# Builds immutable Docker Image, deploying the JAR, above.
cd -
docker login -u="${DOCKER_USERNAME}" -p="${DOCKER_PASSWORD}"
set -ex
sleep 120 # wait for automated Docker Hub build to finish...
IMAGE="garystafford/${SERVICE_NAME}-service"
IMAGE_TAG="${BRANCH}-0.6.${TRAVIS_BUILD_NUMBER}"
docker build -t ${IMAGE}:${IMAGE_TAG} .
docker push ${IMAGE}:${IMAGE_TAG}