Class: GithubBot::Webhooks::GithubController

Inherits:
ApplicationController show all
Defined in:
app/controllers/github_bot/webhooks/github_controller.rb

Overview

Public: The GitHub controller for handling all incoming requests and determining what validator that should be utilized.

Instance Method Summary collapse

Methods inherited from ApplicationController

#event_processing, #valid_request?

Methods included from GithubRequestHelper

#check_run?, #comment_body, #github_event, #github_payload, #github_payload_raw, #github_signature, #issue_comment?, #issue_comment_recheck?, #labeled?, #ping?, #pull_request, #pull_request?, #pull_request_action, #pull_request_review?, #recheck_application?, #repository, #review_request_removed?, #review_requested?, #unlabeled?

Methods included from Response

#json_access_denied, #json_not_found, #json_response

Instance Method Details

#validateObject

POST /webhooks



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/github_bot/webhooks/github_controller.rb', line 11

def validate
  return unless pull_request? || check_run?

  client_api = ::GithubBot::Github::Client.instance

  client_api.repository_pull_request_bots.each do |bot_class|
    clazz =
      begin
        bot_class.constantize
      rescue StandardError => e
        Rails.logger.error(
          message: "#{self.class}##{__method__} Pull request validator '#{bot_class}' is not defined",
          exception: e
        )

        nil
      end

    clazz&.validate
  end
rescue StandardError => e
  Rails.logger.error message: 'GitHub Bot failure', exception: e
end