Skip to content

Instantly share code, notes, and snippets.

@le6o
Created August 1, 2014 13:07
Show Gist options
  • Save le6o/f66e45054d034fe9bb65 to your computer and use it in GitHub Desktop.
Save le6o/f66e45054d034fe9bb65 to your computer and use it in GitHub Desktop.
Capistrano task to tag git revision on deployment
namespace :deploy do
after :finishing, :git_tag do
run_locally do
if fetch(:skip_git_tag, false)
info "[git-tag] Tagging of deployment skipped"
else
user = capture(:git, "config --get user.name")
email = capture(:git, "config --get user.email")
tag_msg = "Deployed by #{user} <#{email}>"
tag_time = Time.new.utc.strftime("%Y%m%d-%H%M%S")
tag_name = "#{fetch :stage}-#{tag_time}"
strategy.git "tag -a #{tag_name} -m \"#{tag_msg}\" #{fetch :current_revision}"
strategy.git "push origin #{tag_name}"
info "[git-tag] Tagged #{fetch :current_revision} with #{tag_name}"
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment