More robust site:publish.
This commit is contained in:
parent
95b07a3c2b
commit
83b3b2a340
22
Rakefile
22
Rakefile
|
@ -133,28 +133,38 @@ namespace :site do
|
|||
sh "cd site && jekyll --server"
|
||||
end
|
||||
|
||||
desc "Commit the local site to the gh-pages branch and deploy"
|
||||
desc "Commit the local site to the gh-pages branch and publish to GitHub Pages"
|
||||
task :publish do
|
||||
# Ensure the gh-pages dir exists so we can generate into it.
|
||||
puts "Checking for gh-pages dir..."
|
||||
unless File.exist?("./gh-pages")
|
||||
puts "No gh-pages directory found. Run the following commands first:"
|
||||
puts " `git clone git@github.com:mojombo/god gh-pages"
|
||||
puts " `git clone git@github.com:mojombo/jekyll gh-pages"
|
||||
puts " `cd gh-pages"
|
||||
puts " `git checkout gh-pages`"
|
||||
exit(1)
|
||||
end
|
||||
|
||||
# Copy the rest of the site over.
|
||||
puts "Copying static..."
|
||||
# Ensure gh-pages branch is up to date.
|
||||
Dir.chdir('gh-pages') do
|
||||
sh "git pull origin gh-pages"
|
||||
end
|
||||
|
||||
# Copy to gh-pages dir.
|
||||
puts "Copying site to gh-pages branch..."
|
||||
Dir.glob("site/*") do |path|
|
||||
next if path == "_site"
|
||||
sh "cp -R #{path} gh-pages/"
|
||||
end
|
||||
|
||||
# Commit the changes
|
||||
# Commit and push.
|
||||
puts "Committing and pushing to GitHub Pages..."
|
||||
sha = `git log`.match(/[a-z0-9]{40}/)[0]
|
||||
sh "cd gh-pages && git add . && git commit -m 'Updating to #{sha}.' && git push"
|
||||
Dir.chdir('gh-pages') do
|
||||
sh "git add ."
|
||||
sh "git commit -m 'Updating to #{sha}.'"
|
||||
sh "git push origin gh-pages"
|
||||
end
|
||||
puts 'Done.'
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue