forked from 18F/tock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
executable file
·44 lines (37 loc) · 1.2 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
36
37
38
39
40
41
42
43
44
#!/bin/sh
set -e
app_name="tock"
timestamp="$(date +"%s")"
current_apps="$(cf apps)"
deploy()
{
current_deployment=$1
next_deployment=$2
echo "building CSS..."
npm run predeploy
echo "$current_deployment is currently deployed, pushing $next_deployment"
cf push $next_deployment --no-start -n $app_name-$timestamp
cf push $next_deployment -n $app_name-$timestamp
echo "Mapping $next_deployment to the Main Domain"
cf map-route $next_deployment 18f.gov -n $app_name
cf map-route $next_deployment 18f.gov -n $app_name --path api
echo "Removing $current_deployment From the Main Domain"
cf unmap-route $current_deployment 18f.gov -n $app_name
cf unmap-route $current_deployment 18f.gov -n $app_name --path api
read -p "Check your app. Is it functioning properly? (y/n)" -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]; then
cf delete $current_deployment -f
else
deploy $next_deployment $current_deployment
fi
}
if [[ $current_apps == *"green"* ]]; then
echo "Green Exists, Deploying Blue"
deploy green blue
elif [[ $current_apps == *"blue"* ]]; then
echo "Blue Exists, Deploying Green"
deploy blue green
else
echo "No existing blue or green app, please create one first!"
fi