Class: Rodbot::Plugins::GithubWebhook::App::Routes

Inherits:
App
  • Object
show all
Defined in:
lib/rodbot/plugins/github_webhook/app.rb

Constant Summary collapse

DEFAULT_HANDLER =
->(request) do
  if request.env['HTTP_X_GITHUB_EVENT'] == 'workflow_run'
    json = JSON.parse(request.body.read)
    project = json.dig('repository', 'full_name')
    status = json.dig('workflow_run', 'status')
    status = json.dig('workflow_run', 'conclusion') if status == 'completed'
    emoji = case status
      when 'requested' then '🟡'
      when 'success' then '🟢'
      when 'failure' then '🔴'
      else '⚪️'
    end
    [emoji, project, status.gsub('_', ' ')].join(' ')
  end
end