-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
104 lines (92 loc) · 4.04 KB
/
.travis.yml
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
services:
- docker
language: node_js
node_js: 12
env:
global:
ENV: dev
SKIP_BUILD: false
notifications:
slack:
secure: Vb/LrucSYa7kHHiKjnskiI30pAsVZM6fxn+xdKmh7iZfgF9YqtuH/fpOi2qe8exbCxG6EzSGjDGW7PvOnwUy65m//gudMWdHsXhQce+gStxPQxaRyf4GrcXiJM6/z5ZO7nAguEmngq8gSbTzFNeJyJIXqqSMvev8SEPAVtyeUaZ92JIgBa7KnmN9vNruNsFHCDKLyeXQVC14y9xiOvuO14GUGeOYn98LUG9MNjQXdQ15VKKE9SRXOhP4fVbAlZ9vniCsJh6haHXZnTRFMjWmPy4vKP5Py8WRC64wrfIykdOqBE/N3Qnp7He10UdW4+dW6uyBx7ZDKtIk1cBopcML2VYh4XIkh8aWLf3QKUh6+iR2qy1VOvRh9bVXTK5O4kvdQVWbqU1owF+cHef2TtkMtPeCWHmfyIDpXIuR9E3LUdSxE+SQM8AQzVYjgzzVx8Q6fT3YNCmUxrsXtPCCYBC4vQkNPr1aHZWgSU6fPQ7Zl6NHN3A6eELcWkGXUQ3/ZA0uwbVmWxv84MrXntlCGSADqxxcMh8iiPgxfafnQej/HQ1yc7lvLBhVZlDrmGaaVngejjvTBsi5LRiRC79/rwvQ8kbJbZlzkSARIotM4Z/TeQDZlCB3GCgjzUOnWelcBS18YCM3XjbVxEcnQwhQzHJncm4mFlVwqZhrx7rQt2AuoDQ=
job_configs:
- gcloud_cache: &gcloud_cache
cache:
directories:
- "$HOME/google-cloud-sdk/"
- gcloud_install: &gcloud_install
# Install the Google Cloud SDK, if not added from Travis cache (see https://cloud.google.com/sdk/docs/downloads-interactive#silent)
# Piping the output to /dev/null is important, as the verbose install script can cause issues on Travis
- if [ ! -d $HOME/google-cloud-sdk/bin ]; then rm -rf $HOME/google-cloud-sdk; curl https://sdk.cloud.google.com > install.sh; bash install.sh --disable-prompts > /dev/null; fi
# Add the Google Cloud SDK command line tools to $PATH
- source $HOME/google-cloud-sdk/path.bash.inc
- gcloud --quiet components update kubectl
- gcloud version
- gcloud_auth: &gcloud_auth
# The Google Cloud key is JSON, but has to be stored as Base64, so decode it
- echo $GCLOUD_SERVICE_KEY | base64 --decode > gcloud.p12
- gcloud auth activate-service-account --key-file gcloud.p12
- gcloud config set project ${GOOGLE_PROJECT_ID}
- gcloud config set compute/zone ${GOOGLE_COMPUTE_ZONE}
- gcloud container clusters get-credentials ${GOOGLE_GKE_CLUSTER}
- build_job: &build_job
install: &get_version
- export BUILD_VERSION="$(git describe)"
- echo "Building ${BUILD_TYPE} docker image ${BUILD_VERSION}"
script:
- cd ${BUILD_TYPE}
- docker build -t reactive-analytics-${BUILD_TYPE}:${BUILD_VERSION} --build-arg BUILD_VERSION=${BUILD_VERSION} .
- build_and_push_job: &build_and_push_job
<<: *gcloud_cache
before_install:
- *gcloud_install
install:
- *get_version
before_script:
- *gcloud_auth
script:
- cd ${BUILD_TYPE}
- docker build -t ${GOOGLE_GCR_HANDLE}/${GOOGLE_PROJECT_ID}/reactive-analytics-${BUILD_TYPE}:${BUILD_VERSION} --build-arg BUILD_VERSION=${BUILD_VERSION} .
- gcloud docker -- push ${GOOGLE_GCR_HANDLE}/${GOOGLE_PROJECT_ID}/reactive-analytics-${BUILD_TYPE}:${BUILD_VERSION}
- deploy_job: &deploy_job
<<: *gcloud_cache
before_install:
- *gcloud_install
install:
- *get_version
before_script:
- *gcloud_auth
script:
- >
for f in ./kubernetes/*.yml; do
cat $f | /usr/bin/envsubst | kubectl --namespace=${NAMESPACE} apply -f -
done
jobs:
include:
- stage: Build
name: Build client
env: BUILD_TYPE=client
<<: *build_job
- name: Build server
env: BUILD_TYPE=server
<<: *build_job
- stage: Build and push
name: Build and push client image
env: BUILD_TYPE=client
<<: *build_and_push_job
- name: Build and push server image
env: BUILD_TYPE=server
<<: *build_and_push_job
- stage: Deploy
name: Deploy images to GKE
language: shell
# use a map of environment variables, not a list, so that a matrix doesn't get created
env: NAMESPACE=${ENV}-reactive-analytics
<<: *deploy_job
stages:
- name: Build
if: env(SKIP_BUILD) != true AND NOT (branch = master AND type IN (push, api))
- name: Build and push
if: env(SKIP_BUILD) != true AND branch = master AND type IN (push, api)
- name: Deploy
if: branch = master AND type IN (push, api)