From 4bb66c12e8afa79d838fd9f0b4c86021050c33eb Mon Sep 17 00:00:00 2001 From: Jonathan Chang Date: Sun, 22 Mar 2020 13:12:06 +1100 Subject: [PATCH] utils/github: add repository_dispatch API --- Library/Homebrew/utils/github.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Library/Homebrew/utils/github.rb b/Library/Homebrew/utils/github.rb index 4e0e42e9eb..7c3b36d284 100644 --- a/Library/Homebrew/utils/github.rb +++ b/Library/Homebrew/utils/github.rb @@ -431,6 +431,13 @@ module GitHub comments.any? { |comment| comment["body"].eql?(body) } end + def dispatch(user, repo, event, **payload) + url = "#{API_URL}/repos/#{user}/#{repo}/dispatches" + open_api(url, data: { event_type: event, client_payload: payload }, + request_method: :POST, + scopes: CREATE_ISSUE_FORK_OR_PR_SCOPES) + end + def api_errors [GitHub::AuthenticationFailedError, GitHub::HTTPNotFoundError, GitHub::RateLimitExceededError, GitHub::Error, JSON::ParserError].freeze