Skip to content

Instantly share code, notes, and snippets.

@gorrillamcd
Created October 22, 2012 19:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gorrillamcd/3933525 to your computer and use it in GitHub Desktop.
Save gorrillamcd/3933525 to your computer and use it in GitHub Desktop.
Raketasks for deploying Octopress generated site to Heroku
desc "deploy basic rack app to heroku"
multitask :heroku do
puts "## Deploying to Heroku "
unless File::exists?(".heroku_failed")
Rake::Task[:generate].execute
end
cd "#{public_dir}" do
system "git add ."
puts "\n## Committing: Site updated at #{Time.now.utc}"
message = "Site updated at #{Time.now.utc}"
system "git commit -m '#{message}'"
puts "\n## Pushing generated #{public_dir} website"
system "git push heroku master"
if $? == 0
File::delete(".heroku_failed") if File::exists?(".heroku_failed")
puts "\n## Heroku deploy complete"
else
File::write(".heroku_failed", "w") unless File::exists?(".heroku_failed")
puts "\n## Heroku deploy had a problem."
end
end
end
desc "Commit Source Changes and deploy to heroku in one fell swoop"
multitask :deploy_heroku do
puts "## Committing changes to source"
system "git status"
if $? == 0
system "git add ."
puts "\n## Committing: Source updated at #{Time.now.utc}"
message = "Source updated at #{Time.now.utc}"
system "git commit -m '#{message}'"
end
Rake::Task[:heroku].execute
end
@gorrillamcd
Copy link
Author

I have my blog techonamission.com on heroku and deploy just the generated site files to keep slug size and memory usage down (running on one dyno). The public_dir variable is set to _heroku/public. That directory is ignored in the git repo for my octopress install and instead is it's own repository/heroku app. To get it to work in this way, I just copied the Gemfile (with just sinatra as a dependency) and the config.ru files so that heroku won't complain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment