3

I have a git repository both on GitHub and on my private Amazon instance and with a unique commit I update both.

There is a way to commit the file database.yml only to my private repository and not on GitHub?

If could help, I'm using Capistrano for deployment.

Marco Sero
  • 460
  • 6
  • 18

2 Answers2

3

In the past days I found no answer to this question, but then I solved my problem, so I'll say what I've done to have things working.

Since I don't have to modify the file database.yml, I solved my problem manually copying it to my Amazon instance and adding it to .gitignore.

Then, I added a task in deploy.rb to link database.yml to the current directory of deployment

# copy db config
after "deploy:update_code", :copy_db_config
desc "copy db config file"
task :copy_db_config do
  run "ln -s ~/path/where/I/copied/database.yml #{release_path}/config/database.yml"
end

Hope this help.

Marco Sero
  • 460
  • 6
  • 18
  • 1
    That's also what I have been doing: http://www.tigraine.at/2011/09/25/securely-managing-database-yml-when-deploying-with-capistrano/ – Tigraine Sep 12 '12 at 21:37
  • @Tigraine Great :) Unfortunately I didn't see your post in the past days.. I could have save _a lot_ of time – Marco Sero Sep 13 '12 at 06:28
0

Another solution is provided here. If you previously define environment variables you can use them in the databases.yml file.

username: <%= ENV['POSTGRES_USERNAME'] %>
password: <%= ENV['POSTGRES_PASSWORD'] %>
Community
  • 1
  • 1
Daniel Hernández
  • 1,279
  • 8
  • 15