Skip to content

Instantly share code, notes, and snippets.

@phil-monroe
Created June 12, 2012 19:44
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 phil-monroe/2919693 to your computer and use it in GitHub Desktop.
Save phil-monroe/2919693 to your computer and use it in GitHub Desktop.
Capistrano tasks to deploy from commit references and separate repos
# 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