Created
February 27, 2014 09:08
-
-
Save tombruijn/9246758 to your computer and use it in GitHub Desktop.
Modified AppSignal deploy task to make it work with Capistrano 3.
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 :appsignal do | |
# Description is required for it to show up in the tasks list. | |
desc 'Notify AppSignal of this deploy!' | |
task :deploy do | |
# 1. Needs to be run inside an `on` block | |
# 2. `appsignal_roles` setting set and supplied with default | |
on roles(fetch(:appsignal_roles, :app)) do | |
env = fetch(:rails_env, 'production') | |
user = ENV['USER'] || ENV['USERNAME'] | |
appsignal_config = Appsignal::Config.new( | |
ENV['PWD'], | |
env, | |
fetch(:appsignal_config, {}), | |
self | |
) | |
if appsignal_config && appsignal_config.active? | |
# `current_revision` method has been removed. | |
# When run from `deploy` the `current_revision` setting should be | |
# set (see: | |
# https://github.com/capistrano/capistrano/blob/3d641ea994627a22edd01529440b12a9e565001d/lib/capistrano/tasks/git.rake#L52 | |
# https://github.com/capistrano/capistrano/blob/5986983915163e6681f2546bf6fad599d58cd024/lib/capistrano/dsl.rb#L32 | |
# ), otherwise (when run with `cap appsignal:deploy`) check again with | |
# `fetch_revision`. | |
marker_data = { | |
revision: fetch(:current_revision) || fetch_revision, | |
repository: fetch(:repo_url), | |
user: user | |
} | |
marker = Appsignal::Marker.new(marker_data, appsignal_config, self) | |
# Dry run conditional removed, now Capistrano does this on a higher level. | |
marker.transmit | |
end | |
end | |
end | |
end | |
after 'deploy', 'appsignal:deploy' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment