Created
April 13, 2018 05:12
-
-
Save hfm/554b510b9487853d321c94e64b2f686b to your computer and use it in GitHub Desktop.
This file contains 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 | |
namespace :mackerel do | |
desc 'Record time deploy strated' | |
task :starting do | |
run_locally { set :deploy_starttime, Time.now.to_i } | |
end | |
desc 'Annotate Mackerel with release url' | |
task :annotate do | |
run_locally do | |
annotation = { | |
service: fetch(:mackerel_service), | |
roles: [ fetch(:mackerel_role) ], | |
from: fetch(:deploy_starttime), | |
to: Time.now.to_i, | |
title: "#{fetch(:project)} deployed", | |
description: "#{fetch(:release_url)} by capistrano" | |
} | |
c = Mackerel::Client.new(mackerel_api_key: ENV['MACKEREL_APIKEY']) | |
c.post_graph_annotation(annotation) | |
end | |
end | |
end | |
end | |
after 'deploy:starting', 'deploy:mackerel:starting' | |
after 'deploy:finishing', 'deploy:mackerel:annotate' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment