-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathlaunch.sh
More file actions
executable file
·119 lines (105 loc) · 2.33 KB
/
launch.sh
File metadata and controls
executable file
·119 lines (105 loc) · 2.33 KB
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/bin/bash
# **********************************************
# launch : launch-test-deploy
#
# see "Design and Build Great Web APIs"
# 2020-04 : @mamund
#
# notes:
# - set up "npm run dev" in package.json (uses nodemon)
# - create test collection in postman (called in test-run.sh)
# - establish heroku app using git (via heroku cli)
#
# assumes:
# - you have npm, package mgmt, and nodemon
# - you have postman collections
# - you have a heroku git remote
#
# direct dependencies:
# - npm
# - git
#
# **********************************************
# **********************************************
# start title
echo
echo "Launching deployment..."
# **********************************************
# exit var
ex=0
# **********************************************
# load config
config="launch.config"
if [ ! -f "$config" ]
then
echo
echo "Missing launch.config"
echo
exit 1
fi
source $config
# **********************************************
# setup killing backgrounds when done
trap "kill 0" EXIT
# **********************************************
# start local instance of service as background
$svc &
# **********************************************
# run pre-deploy test script
ex=1
echo "Running pre-deployment tests..."
cd $test_folder
$test_pre
ex=$?
# **********************************************
# check test status
if [ $ex -gt 0 ]
then
echo "*** PRE-DEPLOY TESTS FAILED - job cancelled. ***"
echo
exit $ex
fi
# **********************************************
# use git push to heroku
if [ $ex -eq 0 ]
then
ex=1
echo "Deploying to production..."
$deploy
ex=$?
fi
# **********************************************
# check heroku status
if [ $ex -gt 0 ]
then
echo "*** DEPLOY FAILED - job cancelled. ***"
echo
exit $ex
fi
# **********************************************
# run post-deploy test script
if [ $ex -eq 0 ]
then
ex=1
echo "Running post-deployment tests..."
$test_post
ex=$?
fi
# **********************************************
# check test status
if [ $ex -gt 0 ]
then
echo "*** POST-DEPLOY TESTS FAILED - job cancelled. ***"
echo
exit $ex
else
echo
echo "*****************************"
echo "*** DEPLOYMENT SUCCESSFUL ***"
echo "*****************************"
date
exit 0
fi
# **********************************************
# EOF
# **********************************************