Created
February 13, 2012 17:58
-
-
Save danielberlinger/1818685 to your computer and use it in GitHub Desktop.
A couple of helpers for capistrano deploys
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
#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