Created
March 10, 2012 19:43
-
-
Save davidjrice/2012655 to your computer and use it in GitHub Desktop.
Clone heroku environment variables to a .env file for foreman
This file contains 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
desc "Clone heroku environment variables to a .env file for foreman'" | |
namespace :heroku do | |
namespace :env do | |
task :clone => :environment do | |
ignore_list = [ | |
"DATABASE_URL", | |
"GEM_PATH", | |
"LANG", | |
"LOG_LEVEL", | |
"PATH", | |
"RACK_ENV", | |
"RAILS_ENV", | |
"SHARED_DATABASE_URL" | |
] | |
puts 'Fetch heroku config' | |
config = `heroku config` | |
output = '' | |
config.lines.each do |line| | |
match = line.match(/([A-Z_]*)\s*=>\s*(.*)/) | |
next if ignore_list.include?(match[1]) | |
output << "#{match[1]}=#{match[2]}\n" | |
end | |
file = "#{Rails.root}/.env" | |
puts "Outputting to #{file}" | |
File.open(file, "w+") do |f| | |
f.write(output) | |
end | |
end | |
end | |
end |
Sweet, I had not seen that. Nice find.
…On Wednesday, 14 March 2012 at 13:37, Michael McClenaghan wrote:
Good idea. I was googling for something that would push my .env file to Heroku and came across this: https://github.com/ddollar/heroku-config. It will do the pull as well.
---
Reply to this email directly or view it on GitHub:
https://gist.github.com/2012655
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Good idea. I was googling for something that would push my .env file to Heroku and came across this: https://github.com/ddollar/heroku-config. It will do the pull as well.