Skip to content

Instantly share code, notes, and snippets.

@danielbeardsley
Created March 1, 2011 16:25
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielbeardsley/849385 to your computer and use it in GitHub Desktop.
Save danielbeardsley/849385 to your computer and use it in GitHub Desktop.
A simple capistrano setup that Auto-creates git tags on deploy, and supports multiple deployment environments
task :production do
# :deployment variable should match task name
set :deployment, 'production'
set :deploy_to, "/home/user/www/#{application}"
set :branch, "master"
find_and_execute_task("deploy:tags:schedule_creation")
end
task :staging do
# :deployment variable should match task name
set :deployment, 'staging'
set :deploy_to, "/home/user/www/staging/#{application}"
set :branch, "master"
find_and_execute_task("deploy:tags:schedule_creation")
end
namespace :deploy do
namespace :tags do
task :schedule_creation do
after "deploy", "deploy:tags:create"
end
task :skip do
set :skip_tag_creation, true
end
desc "Automatically create a git tag in the form 'deploy_yyyy_mm_dd_hh_mm'"
task :create do
if self[:skip_tag_creation]
logger.info("skipping tag creation")
else
tag_name = Time.now.strftime("deploy_%Y_%m_%d_%H_%M")
system "git tag -a -m 'Deployment on #{deployment}' #{tag_name}"
system "git push origin #{tag_name}"
if $? != 0
raise "Pushing tag to origin failed"
end
end
end
end
end
@franciscoj
Copy link

Hey! thanks for such a piece of code! I've used it to build http://github.com/Zorros/zorros-deploy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment