Skip to content

Instantly share code, notes, and snippets.

@davidcornu
Created May 4, 2012 19:45
Show Gist options
  • Save davidcornu/2597272 to your computer and use it in GitHub Desktop.
Save davidcornu/2597272 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
projectroot = File.expand_path("../../", __FILE__)
Dir.chdir(projectroot)
puts <<-INFO
This script pushes all changes in master to the production
branch in addition to cleaning and precompiling assets.
Press ENTER to continue, CTRL-C to exit:
INFO
begin
gets
rescue Interrupt
puts '>> Cancelled'
exit
end
puts '>> Running...'
success = system <<-CMD
git checkout production &&
git pull origin master &&
bundle exec rake assets:clean &&
bundle exec rake assets:precompile &&
git add . &&
git commit -am "Precompiled Assets" &&
git push origin production &&
git checkout master
CMD
if success
puts '>> Complete'
else
puts '>> Error'
end
Copy link

ghost commented May 5, 2012

What happens if theres a conflict in lets say "git pull origin master". Process returns a code that's false so the rest does not execute?

@davidcornu
Copy link
Author

Yup, the && prevents anything else from being executed

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