Various rsync deployment fixups:

1) If ssh_key was absent, you'd get an error.
2) Had to specify full path to key ("/Users/jfrisby/.ssh/...") -- couldn't use "~/.ssh/...".  Since SSH demands it be there anyway, let's pre-populate for the user and make their lives easier.
3) Ensure uniform and consistent trailing slashes on source and dest paths to avoid accidentally mucking things up.
This commit is contained in:
Jon Frisby 2013-02-20 11:38:10 -08:00
parent f64fa33d69
commit d6b6b0d80e

View File

@ -286,6 +286,11 @@ desc "Generate website and deploy"
task :gen_deploy => [:integrate, :generate, :deploy] do
end
def ensure_trailing_slash(val)
val = "#{val}/" unless(val.end_with?('/'))
return val
end
desc "Deploy website via rsync"
task :rsync do
exclude = ""
@ -293,7 +298,9 @@ task :rsync do
exclude = "--exclude-from '#{File.expand_path('./rsync-exclude')}'"
end
puts "## Deploying website via Rsync"
ok_failed system("rsync -avze 'ssh -p #{configuration[:ssh_port]} #{'-i' + configuration[:ssh_key] unless configuration[:ssh_key].empty?}' #{exclude} #{configuration[:rsync_args]} #{"--delete" unless configuration[:rsync_delete] == false} #{configuration[:destination]}/ #{configuration[:ssh_user]}:#{configuration[:document_root]}")
ssh_key = (!configuration[:ssh_key].nil? && !configuration[:ssh_key].empty?) ? "-i #{ENV['HOME']}/.ssh/#{configuration[:ssh_key]}" : ""
document_root = ensure_trailing_slash(configuration[:document_root])
ok_failed system("rsync -avze 'ssh -p #{configuration[:ssh_port]} #{ssh_key}' #{exclude} #{configuration[:rsync_args]} #{"--delete" unless !configuration[:rsync_delete]} #{ensure_trailing_slash(configuration[:destination])} #{configuration[:ssh_user]}:#{document_root}")
end
desc "deploy public directory to github pages"