diff options
author | B Mathis <brandon@imathis.com> | 2009-11-24 16:40:47 -0600 |
---|---|---|
committer | B Mathis <brandon@imathis.com> | 2009-11-24 16:40:47 -0600 |
commit | 54766a0c3b9efe24c61e749e07c2f7c298819c93 (patch) | |
tree | 9e3b494528783c690ed05ba8848b1d6780d16449 /Rakefile | |
parent | e021b70d7912a08cfc05245be1a74b05bfcf37ce (diff) | |
download | my_new_personal_website-54766a0c3b9efe24c61e749e07c2f7c298819c93.tar.xz my_new_personal_website-54766a0c3b9efe24c61e749e07c2f7c298819c93.zip |
updated rakefile to support github pages deployments
Diffstat (limited to '')
-rw-r--r-- | Rakefile | 26 |
1 files changed, 25 insertions, 1 deletions
@@ -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 |