fastlane-plugin-github_api 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +824 -0
- data/lib/fastlane/plugin/github_api/actions/github_add_assignees_action.rb +191 -0
- data/lib/fastlane/plugin/github_api/actions/github_add_issue_comment_action.rb +184 -0
- data/lib/fastlane/plugin/github_api/actions/github_add_labels_action.rb +191 -0
- data/lib/fastlane/plugin/github_api/actions/github_api_action.rb +47 -0
- data/lib/fastlane/plugin/github_api/actions/github_check_pull_merged_action.rb +152 -0
- data/lib/fastlane/plugin/github_api/actions/github_create_commit_comment_reaction_action.rb +168 -0
- data/lib/fastlane/plugin/github_api/actions/github_create_issue_action.rb +199 -0
- data/lib/fastlane/plugin/github_api/actions/github_create_issue_comment_reaction_action.rb +168 -0
- data/lib/fastlane/plugin/github_api/actions/github_create_issue_reaction_action.rb +168 -0
- data/lib/fastlane/plugin/github_api/actions/github_create_label_action.rb +194 -0
- data/lib/fastlane/plugin/github_api/actions/github_create_milestone_action.rb +199 -0
- data/lib/fastlane/plugin/github_api/actions/github_create_pull_action.rb +202 -0
- data/lib/fastlane/plugin/github_api/actions/github_create_pull_comment_action.rb +229 -0
- data/lib/fastlane/plugin/github_api/actions/github_create_pull_comment_reaction_action.rb +168 -0
- data/lib/fastlane/plugin/github_api/actions/github_create_pull_review_action.rb +224 -0
- data/lib/fastlane/plugin/github_api/actions/github_create_repository_action.rb +230 -0
- data/lib/fastlane/plugin/github_api/actions/github_delete_commit_comment_reaction_action.rb +152 -0
- data/lib/fastlane/plugin/github_api/actions/github_delete_issue_comment_action.rb +153 -0
- data/lib/fastlane/plugin/github_api/actions/github_delete_issue_comment_reaction_action.rb +152 -0
- data/lib/fastlane/plugin/github_api/actions/github_delete_issue_reaction_action.rb +152 -0
- data/lib/fastlane/plugin/github_api/actions/github_delete_label_action.rb +164 -0
- data/lib/fastlane/plugin/github_api/actions/github_delete_milestone_action.rb +159 -0
- data/lib/fastlane/plugin/github_api/actions/github_delete_pull_comment_action.rb +144 -0
- data/lib/fastlane/plugin/github_api/actions/github_delete_pull_comment_reaction_action.rb +152 -0
- data/lib/fastlane/plugin/github_api/actions/github_delete_repository_action.rb +166 -0
- data/lib/fastlane/plugin/github_api/actions/github_dismiss_pull_review_action.rb +168 -0
- data/lib/fastlane/plugin/github_api/actions/github_get_issue_action.rb +166 -0
- data/lib/fastlane/plugin/github_api/actions/github_get_issue_comment_action.rb +174 -0
- data/lib/fastlane/plugin/github_api/actions/github_get_issue_event_action.rb +169 -0
- data/lib/fastlane/plugin/github_api/actions/github_get_issue_timeline_action.rb +199 -0
- data/lib/fastlane/plugin/github_api/actions/github_get_milestone_action.rb +167 -0
- data/lib/fastlane/plugin/github_api/actions/github_get_pull_action.rb +150 -0
- data/lib/fastlane/plugin/github_api/actions/github_get_pull_comment_action.rb +147 -0
- data/lib/fastlane/plugin/github_api/actions/github_get_pull_review_action.rb +137 -0
- data/lib/fastlane/plugin/github_api/actions/github_get_pull_review_comments_action.rb +181 -0
- data/lib/fastlane/plugin/github_api/actions/github_list_all_pull_comments_action.rb +186 -0
- data/lib/fastlane/plugin/github_api/actions/github_list_commit_comment_reactions_action.rb +183 -0
- data/lib/fastlane/plugin/github_api/actions/github_list_issue_comment_reactions_action.rb +183 -0
- data/lib/fastlane/plugin/github_api/actions/github_list_issue_comments_action.rb +197 -0
- data/lib/fastlane/plugin/github_api/actions/github_list_issue_events_action.rb +191 -0
- data/lib/fastlane/plugin/github_api/actions/github_list_issue_labels_action.rb +192 -0
- data/lib/fastlane/plugin/github_api/actions/github_list_issue_reactions_action.rb +183 -0
- data/lib/fastlane/plugin/github_api/actions/github_list_issues_action.rb +236 -0
- data/lib/fastlane/plugin/github_api/actions/github_list_milestones_action.rb +205 -0
- data/lib/fastlane/plugin/github_api/actions/github_list_pull_comment_reactions_action.rb +183 -0
- data/lib/fastlane/plugin/github_api/actions/github_list_pull_comments_action.rb +203 -0
- data/lib/fastlane/plugin/github_api/actions/github_list_pull_commits_action.rb +175 -0
- data/lib/fastlane/plugin/github_api/actions/github_list_pull_files_action.rb +174 -0
- data/lib/fastlane/plugin/github_api/actions/github_list_pull_reviewers_action.rb +163 -0
- data/lib/fastlane/plugin/github_api/actions/github_list_pull_reviews_action.rb +175 -0
- data/lib/fastlane/plugin/github_api/actions/github_list_pulls_action.rb +206 -0
- data/lib/fastlane/plugin/github_api/actions/github_list_repo_issue_events_action.rb +185 -0
- data/lib/fastlane/plugin/github_api/actions/github_list_repo_labels_action.rb +184 -0
- data/lib/fastlane/plugin/github_api/actions/github_lock_issue_action.rb +180 -0
- data/lib/fastlane/plugin/github_api/actions/github_merge_pull_action.rb +191 -0
- data/lib/fastlane/plugin/github_api/actions/github_remove_all_labels_action.rb +160 -0
- data/lib/fastlane/plugin/github_api/actions/github_remove_assignees_action.rb +195 -0
- data/lib/fastlane/plugin/github_api/actions/github_remove_label_action.rb +172 -0
- data/lib/fastlane/plugin/github_api/actions/github_remove_pull_reviewers_action.rb +169 -0
- data/lib/fastlane/plugin/github_api/actions/github_request_pull_review_action.rb +169 -0
- data/lib/fastlane/plugin/github_api/actions/github_set_labels_action.rb +191 -0
- data/lib/fastlane/plugin/github_api/actions/github_submit_pull_comment_action.rb +185 -0
- data/lib/fastlane/plugin/github_api/actions/github_submit_pull_review_action.rb +187 -0
- data/lib/fastlane/plugin/github_api/actions/github_unlock_issue_action.rb +157 -0
- data/lib/fastlane/plugin/github_api/actions/github_update_issue_action.rb +202 -0
- data/lib/fastlane/plugin/github_api/actions/github_update_issue_comment_action.rb +172 -0
- data/lib/fastlane/plugin/github_api/actions/github_update_label_action.rb +204 -0
- data/lib/fastlane/plugin/github_api/actions/github_update_milestone_action.rb +198 -0
- data/lib/fastlane/plugin/github_api/actions/github_update_pull_action.rb +191 -0
- data/lib/fastlane/plugin/github_api/actions/github_update_pull_branch_action.rb +158 -0
- data/lib/fastlane/plugin/github_api/actions/github_update_pull_comment_action.rb +156 -0
- data/lib/fastlane/plugin/github_api/actions/github_update_pull_review_action.rb +151 -0
- data/lib/fastlane/plugin/github_api/helper/github_api_helper.rb +123 -0
- data/lib/fastlane/plugin/github_api/version.rb +5 -0
- data/lib/fastlane/plugin/github_api.rb +16 -0
- metadata +120 -0
@@ -0,0 +1,123 @@
|
|
1
|
+
require 'fastlane_core/ui/ui'
|
2
|
+
require 'excon'
|
3
|
+
require 'json'
|
4
|
+
require 'uri'
|
5
|
+
|
6
|
+
module Fastlane
|
7
|
+
module Helper
|
8
|
+
class GithubApiHelper
|
9
|
+
class << self
|
10
|
+
# Make a request to the GitHub API
|
11
|
+
# @param token [String] GitHub API token
|
12
|
+
# @param path [String] API endpoint path
|
13
|
+
# @param params [Hash] Query parameters for GET or body parameters for POST/PUT/PATCH
|
14
|
+
# @param method [Symbol] HTTP method (:get, :post, :put, :patch, :delete)
|
15
|
+
# @param server_url [String] GitHub API server URL
|
16
|
+
# @param headers [Hash] Additional headers to include in the request
|
17
|
+
# @return [Hash] Response from the GitHub API with :status, :body, and :json keys
|
18
|
+
def github_api_request(token: nil, path:, params: nil, method: :get, server_url: nil, headers: {})
|
19
|
+
require 'json'
|
20
|
+
|
21
|
+
# Validate parameters
|
22
|
+
UI.user_error!("No GitHub API token given, pass using `token: 'token'`") if token.to_s.empty?
|
23
|
+
UI.user_error!("GitHub API path cannot be empty") if path.to_s.empty?
|
24
|
+
UI.user_error!("GitHub API server URL cannot be empty") if server_url.to_s.empty?
|
25
|
+
|
26
|
+
# Set up headers
|
27
|
+
request_headers = headers.clone || {}
|
28
|
+
request_headers['User-Agent'] = 'fastlane-github_api'
|
29
|
+
request_headers['Authorization'] = "token #{token}" if token
|
30
|
+
request_headers['Accept'] = 'application/vnd.github.v3+json' unless request_headers.key?('Accept')
|
31
|
+
|
32
|
+
# Handle query parameters for GET requests
|
33
|
+
if method == :get && params && !params.empty?
|
34
|
+
query_string = URI.encode_www_form(params)
|
35
|
+
path = "#{path}?#{query_string}"
|
36
|
+
params = nil
|
37
|
+
end
|
38
|
+
|
39
|
+
# Prepare the URL
|
40
|
+
url = "#{server_url}#{path}"
|
41
|
+
|
42
|
+
begin
|
43
|
+
UI.verbose("#{method.to_s.upcase} : #{url}")
|
44
|
+
|
45
|
+
# Set up Excon options
|
46
|
+
options = {
|
47
|
+
headers: request_headers,
|
48
|
+
middlewares: Excon.defaults[:middlewares] + [Excon::Middleware::RedirectFollower],
|
49
|
+
debug_request: FastlaneCore::Globals.verbose?,
|
50
|
+
debug_response: FastlaneCore::Globals.verbose?
|
51
|
+
}
|
52
|
+
|
53
|
+
# Add body for non-GET requests if params are provided
|
54
|
+
if method != :get && params
|
55
|
+
if params.is_a?(Hash) || params.is_a?(Array)
|
56
|
+
options[:body] = params.to_json
|
57
|
+
request_headers['Content-Type'] = 'application/json'
|
58
|
+
else
|
59
|
+
options[:body] = params
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# Make the request
|
64
|
+
connection = Excon.new(url)
|
65
|
+
response = connection.request(
|
66
|
+
method: method,
|
67
|
+
**options
|
68
|
+
)
|
69
|
+
|
70
|
+
status_code = response.status
|
71
|
+
response_body = response.body.to_s
|
72
|
+
|
73
|
+
# Parse JSON response if available
|
74
|
+
json_response = nil
|
75
|
+
if !response_body.empty? && response.headers['Content-Type'] && response.headers['Content-Type'].include?('application/json')
|
76
|
+
json_response = parse_json(response_body) || {}
|
77
|
+
end
|
78
|
+
|
79
|
+
# Create the response hash with both new format and backward compatibility
|
80
|
+
result = {
|
81
|
+
status: status_code,
|
82
|
+
body: response_body,
|
83
|
+
json: json_response
|
84
|
+
}
|
85
|
+
|
86
|
+
# Add backward compatibility for error handling
|
87
|
+
# Copy json values to top level for backwards compatibility
|
88
|
+
if json_response.is_a?(Hash)
|
89
|
+
json_response.each do |key, value|
|
90
|
+
result[key] = value
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# Add status code at the top level for backward compatibility
|
95
|
+
result['status'] = status_code
|
96
|
+
|
97
|
+
return result
|
98
|
+
rescue => ex
|
99
|
+
error_result = {
|
100
|
+
status: 0,
|
101
|
+
body: ex.message,
|
102
|
+
json: { 'error' => "Network Error: #{ex.message}" }
|
103
|
+
}
|
104
|
+
|
105
|
+
# Add backward compatibility for error handling
|
106
|
+
error_result['error'] = "Network Error: #{ex.message}"
|
107
|
+
error_result['status'] = 0
|
108
|
+
|
109
|
+
return error_result
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
private
|
114
|
+
|
115
|
+
def parse_json(value)
|
116
|
+
JSON.parse(value)
|
117
|
+
rescue JSON::ParserError
|
118
|
+
nil
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'fastlane/plugin/github_api/version'
|
2
|
+
|
3
|
+
module Fastlane
|
4
|
+
module GithubApi
|
5
|
+
# Return all .rb files inside the "actions" and "helper" directory
|
6
|
+
def self.all_classes
|
7
|
+
Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
# By default we want to import all available actions and helpers
|
13
|
+
# A plugin can contain any number of actions and plugins
|
14
|
+
Fastlane::GithubApi.all_classes.each do |current|
|
15
|
+
require current
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fastlane-plugin-github_api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Manish Rathi
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2025-05-09 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email: i.am.manish.rathi@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- LICENSE
|
20
|
+
- README.md
|
21
|
+
- lib/fastlane/plugin/github_api.rb
|
22
|
+
- lib/fastlane/plugin/github_api/actions/github_add_assignees_action.rb
|
23
|
+
- lib/fastlane/plugin/github_api/actions/github_add_issue_comment_action.rb
|
24
|
+
- lib/fastlane/plugin/github_api/actions/github_add_labels_action.rb
|
25
|
+
- lib/fastlane/plugin/github_api/actions/github_api_action.rb
|
26
|
+
- lib/fastlane/plugin/github_api/actions/github_check_pull_merged_action.rb
|
27
|
+
- lib/fastlane/plugin/github_api/actions/github_create_commit_comment_reaction_action.rb
|
28
|
+
- lib/fastlane/plugin/github_api/actions/github_create_issue_action.rb
|
29
|
+
- lib/fastlane/plugin/github_api/actions/github_create_issue_comment_reaction_action.rb
|
30
|
+
- lib/fastlane/plugin/github_api/actions/github_create_issue_reaction_action.rb
|
31
|
+
- lib/fastlane/plugin/github_api/actions/github_create_label_action.rb
|
32
|
+
- lib/fastlane/plugin/github_api/actions/github_create_milestone_action.rb
|
33
|
+
- lib/fastlane/plugin/github_api/actions/github_create_pull_action.rb
|
34
|
+
- lib/fastlane/plugin/github_api/actions/github_create_pull_comment_action.rb
|
35
|
+
- lib/fastlane/plugin/github_api/actions/github_create_pull_comment_reaction_action.rb
|
36
|
+
- lib/fastlane/plugin/github_api/actions/github_create_pull_review_action.rb
|
37
|
+
- lib/fastlane/plugin/github_api/actions/github_create_repository_action.rb
|
38
|
+
- lib/fastlane/plugin/github_api/actions/github_delete_commit_comment_reaction_action.rb
|
39
|
+
- lib/fastlane/plugin/github_api/actions/github_delete_issue_comment_action.rb
|
40
|
+
- lib/fastlane/plugin/github_api/actions/github_delete_issue_comment_reaction_action.rb
|
41
|
+
- lib/fastlane/plugin/github_api/actions/github_delete_issue_reaction_action.rb
|
42
|
+
- lib/fastlane/plugin/github_api/actions/github_delete_label_action.rb
|
43
|
+
- lib/fastlane/plugin/github_api/actions/github_delete_milestone_action.rb
|
44
|
+
- lib/fastlane/plugin/github_api/actions/github_delete_pull_comment_action.rb
|
45
|
+
- lib/fastlane/plugin/github_api/actions/github_delete_pull_comment_reaction_action.rb
|
46
|
+
- lib/fastlane/plugin/github_api/actions/github_delete_repository_action.rb
|
47
|
+
- lib/fastlane/plugin/github_api/actions/github_dismiss_pull_review_action.rb
|
48
|
+
- lib/fastlane/plugin/github_api/actions/github_get_issue_action.rb
|
49
|
+
- lib/fastlane/plugin/github_api/actions/github_get_issue_comment_action.rb
|
50
|
+
- lib/fastlane/plugin/github_api/actions/github_get_issue_event_action.rb
|
51
|
+
- lib/fastlane/plugin/github_api/actions/github_get_issue_timeline_action.rb
|
52
|
+
- lib/fastlane/plugin/github_api/actions/github_get_milestone_action.rb
|
53
|
+
- lib/fastlane/plugin/github_api/actions/github_get_pull_action.rb
|
54
|
+
- lib/fastlane/plugin/github_api/actions/github_get_pull_comment_action.rb
|
55
|
+
- lib/fastlane/plugin/github_api/actions/github_get_pull_review_action.rb
|
56
|
+
- lib/fastlane/plugin/github_api/actions/github_get_pull_review_comments_action.rb
|
57
|
+
- lib/fastlane/plugin/github_api/actions/github_list_all_pull_comments_action.rb
|
58
|
+
- lib/fastlane/plugin/github_api/actions/github_list_commit_comment_reactions_action.rb
|
59
|
+
- lib/fastlane/plugin/github_api/actions/github_list_issue_comment_reactions_action.rb
|
60
|
+
- lib/fastlane/plugin/github_api/actions/github_list_issue_comments_action.rb
|
61
|
+
- lib/fastlane/plugin/github_api/actions/github_list_issue_events_action.rb
|
62
|
+
- lib/fastlane/plugin/github_api/actions/github_list_issue_labels_action.rb
|
63
|
+
- lib/fastlane/plugin/github_api/actions/github_list_issue_reactions_action.rb
|
64
|
+
- lib/fastlane/plugin/github_api/actions/github_list_issues_action.rb
|
65
|
+
- lib/fastlane/plugin/github_api/actions/github_list_milestones_action.rb
|
66
|
+
- lib/fastlane/plugin/github_api/actions/github_list_pull_comment_reactions_action.rb
|
67
|
+
- lib/fastlane/plugin/github_api/actions/github_list_pull_comments_action.rb
|
68
|
+
- lib/fastlane/plugin/github_api/actions/github_list_pull_commits_action.rb
|
69
|
+
- lib/fastlane/plugin/github_api/actions/github_list_pull_files_action.rb
|
70
|
+
- lib/fastlane/plugin/github_api/actions/github_list_pull_reviewers_action.rb
|
71
|
+
- lib/fastlane/plugin/github_api/actions/github_list_pull_reviews_action.rb
|
72
|
+
- lib/fastlane/plugin/github_api/actions/github_list_pulls_action.rb
|
73
|
+
- lib/fastlane/plugin/github_api/actions/github_list_repo_issue_events_action.rb
|
74
|
+
- lib/fastlane/plugin/github_api/actions/github_list_repo_labels_action.rb
|
75
|
+
- lib/fastlane/plugin/github_api/actions/github_lock_issue_action.rb
|
76
|
+
- lib/fastlane/plugin/github_api/actions/github_merge_pull_action.rb
|
77
|
+
- lib/fastlane/plugin/github_api/actions/github_remove_all_labels_action.rb
|
78
|
+
- lib/fastlane/plugin/github_api/actions/github_remove_assignees_action.rb
|
79
|
+
- lib/fastlane/plugin/github_api/actions/github_remove_label_action.rb
|
80
|
+
- lib/fastlane/plugin/github_api/actions/github_remove_pull_reviewers_action.rb
|
81
|
+
- lib/fastlane/plugin/github_api/actions/github_request_pull_review_action.rb
|
82
|
+
- lib/fastlane/plugin/github_api/actions/github_set_labels_action.rb
|
83
|
+
- lib/fastlane/plugin/github_api/actions/github_submit_pull_comment_action.rb
|
84
|
+
- lib/fastlane/plugin/github_api/actions/github_submit_pull_review_action.rb
|
85
|
+
- lib/fastlane/plugin/github_api/actions/github_unlock_issue_action.rb
|
86
|
+
- lib/fastlane/plugin/github_api/actions/github_update_issue_action.rb
|
87
|
+
- lib/fastlane/plugin/github_api/actions/github_update_issue_comment_action.rb
|
88
|
+
- lib/fastlane/plugin/github_api/actions/github_update_label_action.rb
|
89
|
+
- lib/fastlane/plugin/github_api/actions/github_update_milestone_action.rb
|
90
|
+
- lib/fastlane/plugin/github_api/actions/github_update_pull_action.rb
|
91
|
+
- lib/fastlane/plugin/github_api/actions/github_update_pull_branch_action.rb
|
92
|
+
- lib/fastlane/plugin/github_api/actions/github_update_pull_comment_action.rb
|
93
|
+
- lib/fastlane/plugin/github_api/actions/github_update_pull_review_action.rb
|
94
|
+
- lib/fastlane/plugin/github_api/helper/github_api_helper.rb
|
95
|
+
- lib/fastlane/plugin/github_api/version.rb
|
96
|
+
homepage:
|
97
|
+
licenses:
|
98
|
+
- MIT
|
99
|
+
metadata:
|
100
|
+
rubygems_mfa_required: 'true'
|
101
|
+
post_install_message:
|
102
|
+
rdoc_options: []
|
103
|
+
require_paths:
|
104
|
+
- lib
|
105
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '2.6'
|
110
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
requirements: []
|
116
|
+
rubygems_version: 3.4.19
|
117
|
+
signing_key:
|
118
|
+
specification_version: 4
|
119
|
+
summary: A fastlane plugin forGitHub APIs.
|
120
|
+
test_files: []
|