Created
August 1, 2014 13:07
-
-
Save le6o/f66e45054d034fe9bb65 to your computer and use it in GitHub Desktop.
Capistrano task to tag git revision on deployment
This file contains hidden or 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
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