-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
executable file
·86 lines (74 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
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
#!/bin/bash
## Constants
RED="\033[0;31m"
GREEN="\033[0;32m"
Blue="\033[0;34m"
NC="\033[0m"
INFO="\033[0;34m[INFO]\033[0m"
CHECK="${GREEN}✔${NC}"
ERROR="\033[0;31m[ERROR]\033[0m"
function check_if_heroku_installed {
heroku_path="$(command -v heroku)"
if [[ $heroku_path == "/usr/bin/heroku" ]]
then
echo -e "$INFO heroku cli is installed. $CHECK"
else
echo -e "$ERROR heroku cli isn't installed."
exit 1
fi
}
function check_auth_user {
if [[ $(heroku auth:whoami) == "curewellhomeoclinic101@gmail.com" ]]
then
echo -e "$INFO heroku auth user logged in. $CHECK"
else
echo -e "$ERROR heroku - not auth user."
exit 1
fi
}
function check_build_file {
file="$(pwd)/Dockerfile"
if test -f "$file"; then
echo -e "$INFO Dockerfile found. $CHECK"
else
echo -e "$ERROR Dockerfile doesn't exist"
exit 1
fi
}
function checks {
check_if_heroku_installed
# check_auth_user
check_build_file
}
function deploy () {
checks
app_name=""
if [[ $1 == "dev" ]]
then
app_name="curewell-dev"
else
app_name="curewell"
fi
read -p "Deploying to '$app_name', proceed [y/n]: " consent
if [[ $consent == "y" || $consent == "Y" ]]
then
heroku container:push web -a $app_name
heroku container:release web -a $app_name
else
echo -e "$INFO Cancelling deploy to $app_name."
exit 0
fi
}
branch_name=$(git rev-parse --symbolic-full-name --abbrev-ref HEAD)
if [[ $branch_name ]]
then
if [[ $branch_name == "master" ]]
then
deploy $branch_name
else
deploy $branch_name
fi
else
echo -e "$ERROR Unnamed Branch or not a git repository"
exit 1
fi