improved rake file feedback during deploy

This commit is contained in:
B Mathis 2009-11-25 08:18:54 -06:00
parent ffc2962001
commit b12b037091

View File

@ -61,8 +61,7 @@ task :generate_site => [:clean, :generate_style] do
end end
def rebuild_site(relative) def rebuild_site(relative)
puts "\n" puts "\n\n>>> Change Detected to: #{relative} <<<"
puts ">>> Change Detected to: #{relative} <<<"
IO.popen('rake generate_site'){|io| print(io.readpartial(512)) until io.eof?} IO.popen('rake generate_site'){|io| print(io.readpartial(512)) until io.eof?}
puts '>>> Update Complete <<<' puts '>>> Update Complete <<<'
end end
@ -94,23 +93,29 @@ end
desc "generate and deploy website via rsync" desc "generate and deploy website via rsync"
multitask :deploy_rsync => [:default, :clean_debug] do multitask :deploy_rsync => [:default, :clean_debug] do
print ">>> Deploying website <<<" puts ">>> Deploying website to #{site_url} <<<"
ok_failed system("rsync -avz --delete #{site}/ #{ssh_user}:#{document_root}") ok_failed system("rsync -avz --delete #{site}/ #{ssh_user}:#{document_root}")
end end
desc "generate and deploy website to github user pages" desc "generate and deploy website to github user pages"
multitask :deploy_github => [:default, :clean_debug] do multitask :deploy_github => [:default, :clean_debug] do
puts ">>> Deploying #{deploy_branch} branch to Github Pages <<<"
require 'git' require 'git'
repo = Git.open('.') repo = Git.open('.')
puts "\n>>> Checking out #{deploy_branch} branch <<<\n"
repo.branch("#{deploy_branch}").checkout repo.branch("#{deploy_branch}").checkout
(Dir["*"] - [site]).each { |f| rm_rf(f) } (Dir["*"] - [site]).each { |f| rm_rf(f) }
Dir["#{site}/*"].each {|f| mv(f, ".")} Dir["#{site}/*"].each {|f| mv(f, ".")}
rm_rf(site) rm_rf(site)
puts "\n>>> Moving generated site files <<<\n"
Dir["**/*"].each {|f| repo.add(f) } Dir["**/*"].each {|f| repo.add(f) }
repo.status.deleted.each {|f, s| repo.remove(f)} repo.status.deleted.each {|f, s| repo.remove(f)}
puts "\n>>> Commiting: Site updated at #{Time.now.utc} <<<\n"
message = ENV["MESSAGE"] || "Site updated at #{Time.now.utc}" message = ENV["MESSAGE"] || "Site updated at #{Time.now.utc}"
repo.commit(message) repo.commit(message)
puts "\n>>> Pushing generated site to #{deploy_branch} branch <<<\n"
repo.push repo.push
puts "\n>>> Github Pages deploy complete <<<\n"
repo.branch("#{source_branch}").checkout repo.branch("#{source_branch}").checkout
end end