Created
November 19, 2012 14:53
-
-
Save mudge/4111082 to your computer and use it in GitHub Desktop.
Capistrano task to use relative symlinks instead of absolute.
This file contains 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
require "pathname" | |
namespace :deploy do | |
task :create_symlink, :except => { :no_release => true } do | |
deploy_to_pathname = Pathname.new(deploy_to) | |
on_rollback do | |
if previous_release | |
previous_release_pathname = Pathname.new(previous_release) | |
relative_previous_release = previous_release_pathname.relative_path_from(deploy_to_pathname) | |
run "rm -f #{current_path}; ln -s #{relative_previous_release} #{current_path}; true" | |
else | |
logger.important "no previous release to rollback to, rollback of symlink skipped" | |
end | |
end | |
latest_release_pathname = Pathname.new(latest_release) | |
relative_latest_release = latest_release_pathname.relative_path_from(deploy_to_pathname) | |
run "rm -f #{current_path} && ln -s #{relative_latest_release} #{current_path}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A Capistrano 3 equivalent would be cool!