Skip to content

Instantly share code, notes, and snippets.

@mhayes
Created May 15, 2012 23:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhayes/2705867 to your computer and use it in GitHub Desktop.
Save mhayes/2705867 to your computer and use it in GitHub Desktop.
Scan config/*.yml.samples to determine which files need to be symlinked on production
RAILS_ROOT = File.expand_path(File.dirname(File.dirname(__FILE__)))
after "deploy:update_code", "deploy:link_config_files"
before "deploy:assets:precompile", "deploy:link_config_files"
namespace :deploy do
desc "Symlink production config files"
task :link_config_files do
config_files = Dir.glob(Pathname.new(RAILS_ROOT).join("config", "*.yml.sample"))
config_files.each do |file|
f = File.basename(file, ".yml.sample")
run "ln -nfs #{shared_path}/config/#{f}.yml #{release_path}/config/#{f}.yml"
end
end
end
@mhayes
Copy link
Author

mhayes commented May 15, 2012

Now if you have config/database.yml, config/faye.yml, etc these files will automatically be symlinked into your production environment. That way you can keep this sensitive information out of your repository but at the same time not have to worry about forgetting to symlink something on production.

Future ideas:

  • Check to make sure all config/*.yml.sample files have corresponding config/*.yml in production PRIOR to deployment.

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