Skip to content

Instantly share code, notes, and snippets.

@danielberlinger
Created February 13, 2012 17:58
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 danielberlinger/1818685 to your computer and use it in GitHub Desktop.
Save danielberlinger/1818685 to your computer and use it in GitHub Desktop.
A couple of helpers for capistrano deploys
#Speeds up deployment by creating a copy of the project on the server,
set :deploy_via, :remote_cache
task :run_branch_check do
branches_available
check_for_deployment_branch
end
before "deploy", "run_branch_check"
before "deploy:long", "run_branch_check"
def check_for_deployment_branch
return if self[:branch] && branches.include?(self[:branch])
puts "*************************************************************************************"
puts "BRANCHES"
puts "*************************************************************************************"
puts branches
puts "*************************************************************************************"
self[:branch] = Capistrano::CLI.ui.ask("Please enter the branch name which you want to deploy :")
check_for_deployment_branch
end
def branches_available
branches = []
branches = %x[git ls-remote --heads origin | cut -f2 | cut -d"/" -f3].split("\n")
set :branches, branches
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment