Skip to content

Instantly share code, notes, and snippets.

@lenart
Created September 25, 2013 18:44
Show Gist options
  • Save lenart/6704136 to your computer and use it in GitHub Desktop.
Save lenart/6704136 to your computer and use it in GitHub Desktop.
Capistrano tasks to use with figaro gem.
namespace :figaro do
desc "SCP transfer figaro configuration to the shared folder"
task :setup do
transfer :up, "config/application.yml", "#{shared_path}/application.yml", via: :scp
end
desc "Symlink application.yml to the release path"
task :symlink do
run "ln -sf #{shared_path}/application.yml #{latest_release}/config/application.yml"
end
desc "Check if figaro configuration file exists on the server"
task :check do
begin
run "test -f #{shared_path}/application.yml"
rescue Capistrano::CommandError
unless fetch(:force, false)
logger.important 'application.yml file does not exist on the server "shared/application.yml"'
exit
end
end
end
end
after "deploy:setup", "figaro:setup"
after "deploy:create_symlink", "figaro:symlink"
@troynt
Copy link

troynt commented Mar 27, 2014

It is best to symlink at

after 'deploy:finalize_update', 'figaro:symlink'

This will symlink the application.yml earlier in the deploy, allowing you to use elsewhere (e.g. db migrations).

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