Skip to content

Instantly share code, notes, and snippets.

@hfm
Created April 13, 2018 05:12
Show Gist options
  • Save hfm/554b510b9487853d321c94e64b2f686b to your computer and use it in GitHub Desktop.
Save hfm/554b510b9487853d321c94e64b2f686b to your computer and use it in GitHub Desktop.
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