Created
June 12, 2012 19:44
-
-
Save phil-monroe/2919693 to your computer and use it in GitHub Desktop.
Capistrano tasks to deploy from commit references and separate repos
This file contains 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
# Have `cap deploy` ask for tag to deploy from. Can be automated like this `cap deploy TAG=some-tag-name` | |
set :branch do | |
if ENV['REF'] # Tag passed in via arg | |
ref = ENV['REF'] | |
else # Prompt for reference to use | |
default_ref = `git tag`.split("\n").last | |
ref = Capistrano::CLI.ui.ask "Tag to deploy (make sure repo is up to date): [#{default_ref}] " | |
ref = default_ref if ref.empty? | |
end | |
logger.log Logger::INFO, "Deploying with commit reference: #{ref}" | |
ref | |
end | |
set :repository do | |
repo = if ENV['REPO'] | |
ENV['REPO'] | |
elsif ENV['REMOTE'] | |
`git remote show -n #{ENV['REMOTE']} | grep "Push URL"`.split.last | |
else | |
"git@github.com:Default/repo.git" | |
end | |
logger.log Logger::INFO, "Deploying from repo: #{repo}" | |
repo | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment