Created
September 18, 2011 16:00
-
-
Save jamiew/1225205 to your computer and use it in GitHub Desktop.
Jekyll site development, testing deployment. Run `rake` while developing, run `rake deploy` when you're done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
task :default => :server | |
desc 'Start Jekyll server with --auto' | |
task :server do | |
jekyll('--server --auto') | |
end | |
desc 'Build site with Jekyll' | |
task :build do | |
jekyll('--no-auto') | |
# Delete files I don't want to deploy | |
['Rakefile', '*.tmproj'].each do |file| | |
FileUtils.rm_f("_site/#{file}") | |
end | |
end | |
desc 'Test site output for Liquid template errors' | |
task :test => :build do | |
errors = `grep --exclude Rakefile -R 'Liquid error:' _site` | |
if errors.nil? || errors.empty? | |
puts "No errors" | |
else | |
puts "Errors:" | |
puts errors.inspect | |
exit 1 | |
end | |
end | |
desc 'Deploy the website publicly' | |
task :deploy => :test do | |
user = 'jamiew' | |
host = 'server' | |
directory = '~/public_html' | |
sh 'rsync -rtzh --progress --delete _site/ #{user}@#{host}:#{directory}' | |
end | |
task :deploy_github_pages => :test do | |
# TODO echo a warning if you're using plugins, since GH doesn't support them | |
# sh 'git push origin master:gh-pages' # behaves oddly :( | |
sh 'git push origin gh-pages' | |
end | |
def jekyll(opts = '') | |
sh 'rm -rf _site' | |
sh 'jekyll ' + opts | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment