Created
November 11, 2008 22:17
-
-
Save jashmenn/23995 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# 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