Skip to content

Instantly share code, notes, and snippets.

@jashmenn
Created November 11, 2008 22:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jashmenn/23995 to your computer and use it in GitHub Desktop.
Save jashmenn/23995 to your computer and use it in GitHub Desktop.
#
# To use:
# require 'opc/capistrano/ext/upload_config_files'
# upload_config.upload_config_file("config/config.yml", "config/config.yml")
#
module Opc
module Capistrano
module Ext
module UploadConfigFiles
def upload_config_file(source, destination, opts={})
key = source.to_s.gsub(/\W/, "_")
after "deploy:finalize_update", "opc:config:#{key}:put_file", opts
after "deploy:update_code", "opc:config:#{key}:symlink", opts
namespace :opc do
namespace :config do
namespace key do
desc "put #{source} to #{destination}"
task :put_file, opts do
run "mkdir -p #{shared_path}/#{File.dirname(destination)}"
put File.read(source), "#{shared_path}/#{destination}"
end
desc "Make symlink for database yaml files"
task :symlink, opts do
run "ln -nfs #{shared_path}/#{destination} #{release_path}/#{destination}"
end
end
end
end
end
end
end
end
end
Capistrano.plugin :upload_config, Opc::Capistrano::Ext::UploadConfigFiles
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment