diff --git a/rake/site.rake b/rake/site.rake index eb08cc7f..679e4bf0 100644 --- a/rake/site.rake +++ b/rake/site.rake @@ -52,52 +52,14 @@ namespace :site do 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 - # 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..." sha = `git rev-parse HEAD`.strip Dir.chdir('gh-pages') do - sh "git add ." - sh "git commit --allow-empty -m 'Updating to #{sha}.'" - sh "git push origin gh-pages" + sh "git add docs/" + sh "git commit --allow-empty -m 'Generating pages for #{sha}.'" + sh "git push origin master" end puts 'Done.' end