Skip to content

Instantly share code, notes, and snippets.

@voidius
Last active December 9, 2015 13:47
Show Gist options
  • Save voidius/b95eeb32820dad4f8f05 to your computer and use it in GitHub Desktop.
Save voidius/b95eeb32820dad4f8f05 to your computer and use it in GitHub Desktop.
Deploy your local working copy (capistrano >= 3)
# Deploy your local working copy bypassing VCS
#
# Put this file into lib/capistrano/tasks/ and setup, e.g.:
#
# set :rsync_enabled, true
# set :rsync_options, %w[
# --recursive --delete --delete-excluded
# --exclude .git*
# --exclude /test/***
# --exclude /tmp/***
# --exclude /vendor/bundle/***
# --exclude /config/database.yml
# --exclude /config/secrets.yml
# --exclude tags
# --exclude .DS_Store
# ]
#
set :rsync_enabled, false
set :rsync_options, []
Rake::Task["deploy:check"].enhance ["rsync:hook_scm"]
desc "Stage and rsync to the server (or its cache)."
task :rsync do
roles(:all).each do |role|
user = fetch(:user) + "@"
rsync = %w[rsync -avzr]
rsync.concat fetch(:rsync_options)
rsync << "."
rsync << "#{user}#{role.hostname}:#{release_path}"
Kernel.system *rsync
end
end
namespace :rsync do
task :hook_scm do
next unless fetch(:rsync_enabled)
Rake::Task.tasks.each { |task| task.clear if task.name =~ /^#{scm}:/ }
Rake::Task.define_task("#{scm}:check") do
invoke "rsync:check"
end
Rake::Task.define_task("#{scm}:create_release") do
invoke "rsync"
end
end
task :check do
# Everything's a-okay inherently!
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment