Last active
August 29, 2015 14:05
-
-
Save voidius/932c86d7c0c6c7dda98a to your computer and use it in GitHub Desktop.
Deploy from local env
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
| # Deploy your local working copy | |
| # | |
| # | |
| # How to use: | |
| # | |
| # 1. enable rsync in config/deploy/<destination_env>.rb: | |
| # | |
| # set :rsync_enabled, true | |
| # | |
| # 2. run 'cap <destination_env> deploy' | |
| # | |
| 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