update rake task to use docs folder
This commit is contained in:
parent
8b9391da98
commit
a087d34ece
|
@ -52,52 +52,14 @@ namespace :site do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Commit the local site to the gh-pages branch and publish to GitHub Pages"
|
desc "Generate generated pages and publish to GitHub Pages"
|
||||||
task :publish => :generated_pages do
|
task :publish => :generated_pages 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 "Creating gh-pages dir..."
|
|
||||||
sh "git clone git@github.com:jekyll/jekyll gh-pages"
|
|
||||||
end
|
|
||||||
|
|
||||||
# Ensure latest gh-pages branch history.
|
|
||||||
Dir.chdir('gh-pages') do
|
|
||||||
sh "git checkout gh-pages"
|
|
||||||
sh "git pull origin gh-pages"
|
|
||||||
end
|
|
||||||
|
|
||||||
# Proceed to purge all files in case we removed a file in this release.
|
|
||||||
puts "Cleaning gh-pages directory..."
|
|
||||||
purge_exclude = %w[
|
|
||||||
gh-pages/.
|
|
||||||
gh-pages/..
|
|
||||||
gh-pages/.git
|
|
||||||
gh-pages/.gitignore
|
|
||||||
]
|
|
||||||
FileList["gh-pages/{*,.*}"].exclude(*purge_exclude).each do |path|
|
|
||||||
sh "rm -rf #{path}"
|
|
||||||
end
|
|
||||||
|
|
||||||
# Copy site to gh-pages dir.
|
|
||||||
puts "Building site into gh-pages branch..."
|
|
||||||
ENV['JEKYLL_ENV'] = 'production'
|
|
||||||
require "jekyll"
|
|
||||||
Jekyll::Commands::Build.process({
|
|
||||||
"source" => File.expand_path(docs_folder),
|
|
||||||
"destination" => File.expand_path("gh-pages"),
|
|
||||||
"sass" => { "style" => "compressed" }
|
|
||||||
})
|
|
||||||
|
|
||||||
File.open('gh-pages/.nojekyll', 'wb') { |f| f.puts(":dog: food.") }
|
|
||||||
|
|
||||||
# Commit and push.
|
|
||||||
puts "Committing and pushing to GitHub Pages..."
|
puts "Committing and pushing to GitHub Pages..."
|
||||||
sha = `git rev-parse HEAD`.strip
|
sha = `git rev-parse HEAD`.strip
|
||||||
Dir.chdir('gh-pages') do
|
Dir.chdir('gh-pages') do
|
||||||
sh "git add ."
|
sh "git add docs/"
|
||||||
sh "git commit --allow-empty -m 'Updating to #{sha}.'"
|
sh "git commit --allow-empty -m 'Generating pages for #{sha}.'"
|
||||||
sh "git push origin gh-pages"
|
sh "git push origin master"
|
||||||
end
|
end
|
||||||
puts 'Done.'
|
puts 'Done.'
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue