-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdashboard.pipeline.yml
91 lines (89 loc) · 2.22 KB
/
dashboard.pipeline.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
---
stages:
- name: BUILD
inputs:
- type: git
branch: ${REPO_BRANCH}
service: ${REPO}
triggers:
- type: commit
properties:
- name: UI_APP_NAME
value: ${UI_APP_NAME}
- name: REGION_ID
value: ${REGION_ID}
jobs:
- name: Build
type: builder
build_type: shell
script: |-
#!/bin/bash
npm config delete prefix
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.2/install.sh | bash
. ~/.nvm/nvm.sh
nvm install 6.7.0
npm install npm@latest -g
npm install
# Set app's env vars
domain=".mybluemix.net"
case "${REGION_ID}" in
ibm:yp:eu-gb)
domain=".eu-gb.mybluemix.net"
;;
ibm:yp:au-syd)
domain=".au-syd.mybluemix.net"
;;
esac
export SOCKET_URL=https://$UI_APP_NAME$domain
npm run deploy:prod
rm -rf node_modules
- name: DEPLOY
inputs:
- type: job
stage: BUILD
job: Build
triggers:
- type: stage
properties:
- name: REPO_BRANCH
value: ${REPO_BRANCH}
jobs:
- name: Blue/Green Deploy
type: deployer
target:
region_id: ${REGION_ID}
organization: ${ORG_NAME}
space: ${SPACE_NAME}
application: ${CF_APP_NAME}
script: |-
#!/bin/bash
# The branch may use a custom manifest
MANIFEST=manifest.yml
if [ -f ${REPO_BRANCH}-manifest.yml ]; then
MANIFEST=${REPO_BRANCH}-manifest.yml
PREFIX=$REPO_BRANCH"-"
fi
echo "Using manifest file: $MANIFEST"
echo "Using prefix: $PREFIX"
# Create CF services
cf create-service cloudantNoSQLDB Lite ${PREFIX}insurance-bot-db
cf create-service tone_analyzer standard insurance-tone_analyzer
if ! cf app $CF_APP; then
cf push $CF_APP -n $CF_APP -f $MANIFEST
else
OLD_CF_APP=${CF_APP}-OLD-$(date +"%s")
rollback() {
set +e
if cf app $OLD_CF_APP; then
cf logs $CF_APP --recent
cf delete $CF_APP -f
cf rename $OLD_CF_APP $CF_APP
fi
exit 1
}
set -e
trap rollback ERR
cf rename $CF_APP $OLD_CF_APP
cf push $CF_APP -n $CF_APP -f $MANIFEST
cf delete $OLD_CF_APP -f
fi