Skip to content

Instantly share code, notes, and snippets.

@michiels
Created August 21, 2013 14:15
Show Gist options
  • Select an option

  • Save michiels/6295011 to your computer and use it in GitHub Desktop.

Select an option

Save michiels/6295011 to your computer and use it in GitHub Desktop.
Don't allow someone to deploy a feature branch when there's already one active
if ENV['BRANCH']
before "deploy", "deploy:check_branch"
end
after "deploy:finalize_update", "deploy:put_branch"
namespace :deploy do
task :check_branch do
current_branch = capture("cat #{current_path}/BRANCH; true")
if branch != 'master' && current_branch != 'master' && current_branch != `git rev-parse --abbrev-rev HEAD`
puts 'Sorry, someone else is already deploying a feature branch.'
exit
end
end
task :put_branch do
put "#{branch}", "#{release_path}/BRANCH"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment