Last active
August 7, 2018 20:24
-
-
Save armandfardeau/0a1924fa2011d9ab47ac78bdce00a312 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace :heroku do | |
| desc "Deploy a test version on heroku" | |
| task setup: :environment do | |
| if ENV["SECRET_KEY_BASE"].nil? | |
| puts "No SECRET_KEY_BASE found !" | |
| puts "export SECRET_KEY_BASE first : " | |
| puts "export SECRET_KEY_BASE=#{`bundle exe rake secret`}" | |
| exit 1 | |
| end | |
| app_name_raw = `git rev-parse --abbrev-ref HEAD` | |
| digit = /\d.\d.-/.match(app_name_raw) | |
| if digit.nil? | |
| app_name = app_name_raw.gsub("_", "-")[0..29].chomp | |
| else | |
| app_name = app_name_raw.gsub(digit[0], "").gsub("_", "-")[0..29].chomp | |
| end | |
| org_name = "osp-ext" | |
| if system("heroku create #{app_name} --region eu --org #{org_name}") | |
| system("heroku addons:create heroku-postgresql:hobby-dev -a #{app_name}") | |
| system("heroku addons:create newrelic:wayne -a #{app_name}") | |
| system("heroku addons:create heroku-redis:hobby-dev -a #{app_name}") | |
| system("heroku addons:create memcachedcloud:30 -a #{app_name}") | |
| system("heroku addons:create sentry:f1 -a #{app_name}") | |
| system("heroku addons:create sendgrid:starter -a #{app_name}") | |
| system("heroku labs:enable runtime-dyno-metadata -a #{app_name}") | |
| system("heroku config:set SEED=true -a #{app_name}") | |
| system("heroku config:set SKIP_FIRST_LOGIN_AUTHORIZATION=true -a #{app_name}") | |
| system("heroku config:set SECRET_KEY_BASE=$SECRET_KEY_BASE -a #{app_name}") | |
| #system("#heroku config:set AWS_ACCESS_KEY, OMNIAUTH_FACEBOOK, etc if needed") | |
| system("heroku git:remote -a #{app_name}") | |
| system("git push heroku $(git rev-parse --abbrev-ref HEAD):master") | |
| end | |
| end | |
| task push: :environment do | |
| system("git push heroku $(git rev-parse --abbrev-ref HEAD):master") | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment