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"
|
sh "cd site && jekyll --server"
|
||||||
end
|
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
|
task :publish do
|
||||||
# Ensure the gh-pages dir exists so we can generate into it.
|
# Ensure the gh-pages dir exists so we can generate into it.
|
||||||
puts "Checking for gh-pages dir..."
|
puts "Checking for gh-pages dir..."
|
||||||
unless File.exist?("./gh-pages")
|
unless File.exist?("./gh-pages")
|
||||||
puts "No gh-pages directory found. Run the following commands first:"
|
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 " `cd gh-pages"
|
||||||
puts " `git checkout gh-pages`"
|
puts " `git checkout gh-pages`"
|
||||||
exit(1)
|
exit(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Copy the rest of the site over.
|
# Ensure gh-pages branch is up to date.
|
||||||
puts "Copying static..."
|
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|
|
Dir.glob("site/*") do |path|
|
||||||
next if path == "_site"
|
next if path == "_site"
|
||||||
sh "cp -R #{path} gh-pages/"
|
sh "cp -R #{path} gh-pages/"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Commit the changes
|
# Commit and push.
|
||||||
|
puts "Committing and pushing to GitHub Pages..."
|
||||||
sha = `git log`.match(/[a-z0-9]{40}/)[0]
|
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.'
|
puts 'Done.'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue