forked from alejandrogq/rails3-templates
-
Notifications
You must be signed in to change notification settings - Fork 0
/
heroku.rb
49 lines (39 loc) · 1.58 KB
/
heroku.rb
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
def heroku(cmd, arguments="")
run "heroku #{cmd} #{arguments}"
end
envs = ask "\r\n\r\nEnter the list of environments to deploy NOW on heroku separated by commas, e.g.: staging, production (Leave empty for none):"
app_name = ask "\r\n\r\nEnter the application name to use on heroku:" unless envs.empty?
gem "heroku"
run "bundle install"
file ".slugignore", <<-EOS.gsub(/^ /, '')
*.psd
*.pdf
test
spec
features
doc
docs
EOS
# The system in heroku is read-only (except for log and tmp)
# Instead of letting the server compile the stylesheets when the requests hits the server
# we commit the compiled stylesheets to the git repo
# and tell compass to never compile
append_file 'config/environments/production.rb', 'Sass::Plugin.options[:never_update] = true'
run "cp config/environments/production.rb config/environments/staging.rb"
gsub_file '.gitignore', /^public\/stylesheets$/, ''
run "bundle exec compass compile --output-style compressed --force"
git :add => '.'
git :commit => "-a -m 'Configuration for heroku'"
envs.split(", ").each do |env|
next unless ["staging", "production"].include?(env)
heroku :create, "#{app_name}-#{env} --remote heroku-#{env}"
heroku :"config:add", "BUNDLE_WITHOUT='development:test' --app #{app_name}-#{env}"
heroku :"config:add", "RACK_ENV=#{env} --app #{app_name}-#{env}"
# addons
heroku :"addons:add", "custom_domains:basic"
heroku :"addons:add", "newrelic:bronze"
heroku :"addons:add", "cron:daily"
git :push => "heroku-#{env} master"
heroku :rake, "db:migrate --app #{app_name}-#{env}"
heroku :open, "--app #{app_name}-#{env}"
end