forked from DScheglov/ehealth.api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
executable file
·35 lines (35 loc) · 1.55 KB
/
deploy.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
#!/bin/bash
if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
if [ "$TRAVIS_BRANCH" == "$TRUNK_BRANCH" ]; then
## install kubectl
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
## Install helm
curl https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get > get_helm.sh
chmod 700 get_helm.sh
./get_helm.sh
# Credentials to GCE
gcloud auth activate-service-account --key-file=$TRAVIS_BUILD_DIR/eHealth-8110bd102a69.json
gcloud container clusters get-credentials dev --zone europe-west1-d --project ehealth-162117
#get helm charts
git clone https://[email protected]/edenlabllc/ehealth.charts.git
cd ehealth.charts
#get version and project name
sed -i'' -e "1,10s/tag:.*/tag: \"$NEXT_VERSION\"/g" "$Chart/values.yaml"
helm init --upgrade
sleep 15
helm upgrade -f $Chart/values.yaml $Chart $Chart
cd $TRAVIS_BUILD_DIR/bin
./wait-for-deployment.sh api $Chart 180
if [ "$?" -eq 0 ]; then
kubectl get pod -n$Chart | grep api
cd $TRAVIS_BUILD_DIR/ehealth.charts && git add . && sudo git commit -m "Bump $Chart api to $NEXT_VERSION" && sudo git pull && sudo git push
exit 0;
else
kubectl logs $(sudo kubectl get pod -n$Chart | awk '{ print $1 }' | grep api) -n$Chart
helm rollback $Chart $(($(helm ls | grep $Chart | awk '{ print $2 }') -1))
exit 1;
fi;
fi;
fi;