appsignal / appsignal-ruby

🟥 AppSignal for Ruby gem
https://www.appsignal.com/ruby
MIT License
181 stars 115 forks source link

Support mina deploy #576

Open risen opened 4 years ago

risen commented 4 years ago

We're using mina instead of capistrano to deploy. It'd be nice to have out of the box support for AppSignal deploy markers.

Right now we're using something like this:

namespace :appsignal do
  task :deploy do
    in_path "#{fetch(:current_path)}" do
      command %{#{fetch(:bundle_prefix)} appsignal notify_of_deploy --revision=`cat #{fetch(:current_path)}/.mina_git_revision` --user=#{ENV['USER'] || ENV['USERNAME']} --environment=#{fetch(:rails_env)}}
    end
  end
end

… which uses the deprecated (?) CLI command.

Or this:

default: &defaults
  push_api_key: "api_key"
  name: "app_name"
  revision: <%= File.read(Rails.root.join('.mina_git_revision')).strip if Rails.root.join('.mina_git_revision').exist? %>

… which works too but doesn't include the username in the deploy.

There's not :current_revision variable in mina, so it's a bit clumsy to use a remote (server-side) revision to execute local ruby code for the deploy notification. Proper support would be nice.

Thanks!

tombruijn commented 4 years ago

Hi @risen,

Thanks for the request! We've been meaning to add support for the user name to the revision option.

For mina support, and better capistrano support so they don't use the deprecated option, we will have to look into the best way to read the revision from the app. I currently wouldn't know of a better way than to write a file on deploy and read it on boot.

nickhammond commented 2 years ago

I stumbled across this issue when trying to get Mina and AppSignal working together, there is a third party gem(mina-appsignal) that utilizes curl to create a deploy marker. I created a PR to update the mina dependency so you can still use it with the latest Mina as well.