-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.bash
executable file
·47 lines (39 loc) · 1 KB
/
deploy.bash
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
#!/bin/bash
function show_help() {
echo "Usage: $0 <type-of-deployment> <heroku-dyno-name>"
}
if [[ -z "$1" || "$1" == "help" ]]; then
show_help
exit 1
fi
if [[ "$1" != "api" && "$1" != "web" ]]; then
echo "ERROR: First argument to $0 must be 'api' or 'web'"
echo ""
show_help
exit 1
fi
if [[ -z "$2" ]]; then
echo "ERROR: Second argument to $0 must be heroku server name"
echo ""
show_help
exit 1
fi
if [[ $(git branch | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1/") != "master" ]]; then
echo "ERROR: Must be on git master branch"
echo ""
show_help
exit 1
fi
heroku git:remote -a "$2"
if [[ "$1" = "api" ]]; then
# Before pushing to Heroku we need to commit the Procfile.
echo "web: yarn start_api:prod" > Procfile
git add Procfile
git commit -m "Add Procfile"
git push -f heroku master
# Remove the commit that added the Procfile for the deployment.
git reset --hard HEAD^
fi
if [[ "$1" = "web" ]]; then
git push -f heroku master
fi