Tiago Scolari

bits for fun

Keeping track of your deploys with capistrano and git

2012-02-19

I’ve created a simple capistrano task to keep track of my deploys. When I deploy to a server, it will create a git tag and push it to origin. This way I can keep track of each deploy revision.

after 'deploy:update_code', 'git:create_deploy_tag'

namespace :git
  task :create_deploy_tag do
    puts "[git] creating new deploy tag"
    tag_name = "deploy--#{Time.now.strftime("%Y-%m-%d-%H-%M-%S")}"
    `git tag -a '#{tag_name}' -m 'Deploy: #{Time.now}' origin/production && git push origin --tags`
   end
end

p.s: I use the production branch as my deploy branch. You can change it for master, or anything else.