-
Notifications
You must be signed in to change notification settings - Fork 74
/
setup_heroku
executable file
·76 lines (59 loc) · 2.07 KB
/
setup_heroku
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
#!/bin/sh
set -e
while getopts ":a:o:" opt; do
case $opt in
a)
APP_NAME=$OPTARG
;;
o)
OHANA_API_ENDPOINT=$OPTARG
;;
\?)
echo "Invalid option: -$OPTARG" >&2
echo "Usage: setup_heroku -a your_app_name -o your_api_endpoint" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument" >&2
echo "Usage: setup_heroku -a your_app_name -o your_api_endpoint" >&2
exit 1
;;
esac
done
# Guard clause for APP_NAME option
if [ -z "$APP_NAME" ]; then
echo "Please provide a Heroku application name using the -a option." >&2
exit 201
fi
# Guard clause for OHANA_API_ENDPOINT option
if [ -z "$OHANA_API_ENDPOINT" ]; then
echo "Please provide an Ohana API endpoint using the -o option." >&2
exit 202
fi
# Heroku setup
echo "Getting ready to set environment variables for $APP_NAME"
echo "Setting CANONICAL_URL"
heroku config:set CANONICAL_URL=$APP_NAME.herokuapp.com --app $APP_NAME
echo "Setting DOMAIN_NAME"
heroku config:set DOMAIN_NAME=$APP_NAME.herokuapp.com --app $APP_NAME
echo "Setting OHANA_API_ENDPOINT"
heroku config:set OHANA_API_ENDPOINT=$OHANA_API_ENDPOINT --app $APP_NAME
echo "Setting RAILS_LOG_TO_STDOUT to true"
heroku config:set RAILS_LOG_TO_STDOUT=true --app $APP_NAME
echo "Setting RAILS_SERVE_STATIC_FILES to true"
heroku config:set RAILS_SERVE_STATIC_FILES=true --app $APP_NAME
echo "Setting SECRET_TOKEN"
token=$(python -c 'import uuid; print uuid.uuid4()')
heroku config:set SECRET_TOKEN=$token --app $APP_NAME
echo "Getting ready to install add-ons for $APP_NAME"
echo "Installing SendGrid"
heroku addons:create sendgrid:starter --app $APP_NAME
echo "Installing Memcachier"
heroku addons:create memcachier --app $APP_NAME
echo "Adding NodeJS buildback for compatibility with webpacker"
heroku buildpacks:add heroku/nodejs -i 1 --app $APP_NAME
echo "All done setting up env vars and add-ons."
echo "Pushing code to Heroku now. This will take a few minutes..."
git push heroku master
echo "All done pushing code."
echo "You can now visit your site at https://$APP_NAME.herokuapp.com"