Skip to content

Commit

Permalink
updated rakefile to support github pages deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
imathis committed Nov 24, 2009
1 parent e021b70 commit 54766a0
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion Rakefile
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 54766a0

Please sign in to comment.