Update rake task site:publish to fix minor bugs.

*  Automate creating gh-pages directory
*  Ensure gh-pages dir always has correct branch checked out
*  Purge gh-pages of files so that a sync of site truly occurs
*  Ensure dot files are synced
*  Be exact with our exclusions to eliminate guess work
This commit is contained in:
Alan Scherger 2015-01-03 19:43:55 -08:00
parent 51951c43e8
commit 7f370cb82f
1 changed files with 19 additions and 9 deletions

View File

@ -179,22 +179,32 @@ namespace :site 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 "Creating gh-pages dir..."
puts " `git clone git@github.com:jekyll/jekyll gh-pages" sh "git clone git@github.com:jekyll/jekyll gh-pages"
puts " `cd gh-pages"
puts " `git checkout gh-pages`"
exit(1)
end end
# Ensure gh-pages branch is up to date. # Ensure latest gh-pages branch history.
Dir.chdir('gh-pages') do Dir.chdir('gh-pages') do
sh "git checkout gh-pages"
sh "git pull origin gh-pages" sh "git pull origin gh-pages"
end end
# Copy to gh-pages dir. # Proceed to purge all files in case we removed a file in this release.
puts "Cleaning gh-pages directory..."
Dir.glob("gh-pages/{*,.*}") do |path|
next if path.eql? "gh-pages/."
next if path.eql? "gh-pages/.."
next if path.eql? "gh-pages/.git"
sh "rm -rf #{path}"
end
# Copy site to gh-pages dir.
puts "Copying site to gh-pages branch..." puts "Copying site to gh-pages branch..."
Dir.glob("site/*") do |path| Dir.glob("site/{*,.*}") do |path|
next if path.include? "_site" next if path.eql? "site/."
next if path.eql? "site/.."
next if path.eql? "site/.jekyll-metadata"
next if path.eql? "site/_site"
sh "cp -R #{path} gh-pages/" sh "cp -R #{path} gh-pages/"
end end