Skip to content

Instantly share code, notes, and snippets.

@dlip
Last active March 10, 2016 22:51
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dlip/8799791 to your computer and use it in GitHub Desktop.
Save dlip/8799791 to your computer and use it in GitHub Desktop.
Capistrano 3 deploy notification email with git diff
require 'mail'
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 "deploy@foo.com"
to "team@foo.com"
subject "Deploy Notification #{current_revision} (#{fetch :stage})"
body "Current Revision #{current_revision}\nPrevious Revision: #{previous_revision}\n\n#{log}"
end
end
end
gem 'mail'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment