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:
parent
51951c43e8
commit
7f370cb82f
28
Rakefile
28
Rakefile
|
@ -179,22 +179,32 @@ namespace :site 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:jekyll/jekyll gh-pages"
|
||||
puts " `cd gh-pages"
|
||||
puts " `git checkout gh-pages`"
|
||||
exit(1)
|
||||
puts "Creating gh-pages dir..."
|
||||
sh "git clone git@github.com:jekyll/jekyll gh-pages"
|
||||
end
|
||||
|
||||
# Ensure gh-pages branch is up to date.
|
||||
# Ensure latest gh-pages branch history.
|
||||
Dir.chdir('gh-pages') do
|
||||
sh "git checkout gh-pages"
|
||||
sh "git pull origin gh-pages"
|
||||
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..."
|
||||
Dir.glob("site/*") do |path|
|
||||
next if path.include? "_site"
|
||||
Dir.glob("site/{*,.*}") do |path|
|
||||
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/"
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue