From 54766a0c3b9efe24c61e749e07c2f7c298819c93 Mon Sep 17 00:00:00 2001 From: B Mathis Date: Tue, 24 Nov 2009 16:40:47 -0600 Subject: updated rakefile to support github pages deployments --- Rakefile | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index d8d07c9e..5d1816b0 100644 --- a/Rakefile +++ b/Rakefile @@ -10,6 +10,14 @@ port = "4000" # preview project port eg. http://localhost:4000 site = "site" # compiled site directory source = "source" # source file directory +# Github pages deploy config +# For github user pages, use "master" +# For github project pages use "gh-pages" +# If you're not using this, you can remove it +# Read http://pages.github.com for guidance + +github_pages_branch = "gh-pages" + def ok_failed(condition) if (condition) puts "OK" @@ -86,11 +94,27 @@ task :watch do end desc "generate and deploy website" -multitask :deploy => [:default, :clean_debug] do +multitask :deploy_rsync => [:default, :clean_debug] do print ">>> Deploying website <<<" ok_failed system("rsync -avz --delete #{site}/ #{ssh_user}:#{document_root}") end +desc "generate and deploy website to github user pages" +multitask :github_user_deploy => [:default, :clean_debug] do + require 'git' + repo = Git.open('.') + repo.branch("#{github_pages_branch}").checkout + (Dir["*"] - ["#{site}/*"]).each { |f| rm_rf(f) } + Dir["#{site}/*"].each {|f| mv(f, ".")} + rm_rf("#{site}/*") + Dir["**/*"].each {|f| repo.add(f) } + repo.status.deleted.each {|f, s| repo.remove(f)} + message = ENV["MESSAGE"] || "Site updated at #{Time.now.utc}" + repo.commit(message) + repo.push + repo.branch("source").checkout +end + desc "start up an instance of serve on the output files" task :start_serve => :stop_serve do cd "#{site}" do -- cgit v1.2.1