Last active
March 10, 2016 22:51
-
-
Save dlip/8799791 to your computer and use it in GitHub Desktop.
Capistrano 3 deploy notification email with git diff
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
require 'mail' |
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 | |
task :notify do | |
Mail.defaults do | |
delivery_method :smtp, address: "smtp.foo.com", port: 25 | |
end | |
current_revision = fetch :current_revision | |
previous_revision = fetch :previous_revision | |
log = "" | |
on roles(:web) do | |
within release_path do | |
log = capture("cd #{repo_path} && git --no-pager log --pretty=\"format:%h - %s (%ar) <%an>\" #{previous_revision}..#{current_revision}") | |
end | |
end | |
Mail.deliver do | |
from "[email protected]" | |
to "[email protected]" | |
subject "Deploy Notification #{current_revision} (#{fetch :stage})" | |
body "Current Revision #{current_revision}\nPrevious Revision: #{previous_revision}\n\n#{log}" | |
end | |
end | |
end |
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
gem 'mail' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment