Skip to content

Instantly share code, notes, and snippets.

@davidjrice
Created March 10, 2012 19:43
Show Gist options
  • Select an option

  • Save davidjrice/2012655 to your computer and use it in GitHub Desktop.

Select an option

Save davidjrice/2012655 to your computer and use it in GitHub Desktop.
Clone heroku environment variables to a .env file for foreman
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
@mm53bar
Copy link
Copy Markdown

mm53bar commented Mar 14, 2012

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.

@davidjrice
Copy link
Copy Markdown
Author

davidjrice commented Mar 14, 2012 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment