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,137 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/github_api_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
module SharedValues
|
7
|
+
GITHUB_GET_PULL_REVIEW_STATUS_CODE = :GITHUB_GET_PULL_REVIEW_STATUS_CODE
|
8
|
+
GITHUB_GET_PULL_REVIEW_RESPONSE = :GITHUB_GET_PULL_REVIEW_RESPONSE
|
9
|
+
GITHUB_GET_PULL_REVIEW_JSON = :GITHUB_GET_PULL_REVIEW_JSON
|
10
|
+
end
|
11
|
+
|
12
|
+
class GithubGetPullReviewAction < Action
|
13
|
+
class << self
|
14
|
+
def run(params)
|
15
|
+
require 'json'
|
16
|
+
|
17
|
+
# Prepare API call parameters
|
18
|
+
server_url = params[:server_url]
|
19
|
+
api_token = params[:api_token]
|
20
|
+
repo_owner = params[:repo_owner]
|
21
|
+
repo_name = params[:repo_name]
|
22
|
+
pull_number = params[:pull_number]
|
23
|
+
review_id = params[:review_id]
|
24
|
+
|
25
|
+
# Build the path
|
26
|
+
path = "/repos/#{repo_owner}/#{repo_name}/pulls/#{pull_number}/reviews/#{review_id}"
|
27
|
+
|
28
|
+
UI.message("Getting review #{review_id} for pull request ##{pull_number} in #{repo_owner}/#{repo_name}")
|
29
|
+
response = Helper::GithubApiHelper.github_api_request(
|
30
|
+
token: api_token,
|
31
|
+
path: path,
|
32
|
+
method: :get,
|
33
|
+
server_url: server_url
|
34
|
+
)
|
35
|
+
|
36
|
+
status_code = response[:status]
|
37
|
+
json_response = response[:json]
|
38
|
+
result = {
|
39
|
+
status: status_code,
|
40
|
+
body: response[:body],
|
41
|
+
json: json_response
|
42
|
+
}
|
43
|
+
|
44
|
+
if status_code.between?(200, 299)
|
45
|
+
UI.success("Successfully retrieved review #{review_id} for pull request ##{pull_number}")
|
46
|
+
else
|
47
|
+
UI.error("Error getting pull request review: #{status_code}")
|
48
|
+
UI.error(response[:body])
|
49
|
+
UI.user_error!("GitHub API returned #{status_code}: #{response[:body]}")
|
50
|
+
return nil
|
51
|
+
end
|
52
|
+
|
53
|
+
# Store the results in shared values
|
54
|
+
Actions.lane_context[SharedValues::GITHUB_GET_PULL_REVIEW_STATUS_CODE] = status_code
|
55
|
+
Actions.lane_context[SharedValues::GITHUB_GET_PULL_REVIEW_RESPONSE] = response[:body]
|
56
|
+
Actions.lane_context[SharedValues::GITHUB_GET_PULL_REVIEW_JSON] = json_response
|
57
|
+
|
58
|
+
return result
|
59
|
+
end
|
60
|
+
|
61
|
+
#####################################################
|
62
|
+
# @!group Documentation
|
63
|
+
#####################################################
|
64
|
+
|
65
|
+
def description
|
66
|
+
"Gets a single review for a pull request"
|
67
|
+
end
|
68
|
+
|
69
|
+
def details
|
70
|
+
[
|
71
|
+
"Gets detailed information about a specific review for a pull request.",
|
72
|
+
"You must provide your GitHub Personal token (get one from https://github.com/settings/tokens/new).",
|
73
|
+
"API Documentation: https://docs.github.com/en/rest/pulls/reviews#get-a-review-for-a-pull-request"
|
74
|
+
].join("\n")
|
75
|
+
end
|
76
|
+
|
77
|
+
def available_options
|
78
|
+
[
|
79
|
+
FastlaneCore::ConfigItem.new(key: :api_token,
|
80
|
+
env_name: "GITHUB_API_TOKEN",
|
81
|
+
description: "GitHub API token",
|
82
|
+
optional: false,
|
83
|
+
sensitive: true,
|
84
|
+
code_gen_sensitive: true,
|
85
|
+
default_value: ENV["GITHUB_API_TOKEN"],
|
86
|
+
verify_block: proc do |value|
|
87
|
+
UI.user_error!("No GitHub API token given, pass using `api_token: 'token'`") if value.to_s.empty?
|
88
|
+
end),
|
89
|
+
FastlaneCore::ConfigItem.new(key: :server_url,
|
90
|
+
env_name: "GITHUB_API_SERVER_URL",
|
91
|
+
description: "GitHub API server URL",
|
92
|
+
optional: true,
|
93
|
+
default_value: "https://api.github.com"),
|
94
|
+
FastlaneCore::ConfigItem.new(key: :repo_owner,
|
95
|
+
env_name: "GITHUB_API_REPO_OWNER",
|
96
|
+
description: "Owner of the repository",
|
97
|
+
optional: false),
|
98
|
+
FastlaneCore::ConfigItem.new(key: :repo_name,
|
99
|
+
env_name: "GITHUB_API_REPO_NAME",
|
100
|
+
description: "Name of the repository",
|
101
|
+
optional: false),
|
102
|
+
FastlaneCore::ConfigItem.new(key: :pull_number,
|
103
|
+
env_name: "GITHUB_API_PULL_NUMBER",
|
104
|
+
description: "The number of the pull request",
|
105
|
+
optional: false,
|
106
|
+
type: Integer),
|
107
|
+
FastlaneCore::ConfigItem.new(key: :review_id,
|
108
|
+
env_name: "GITHUB_API_REVIEW_ID",
|
109
|
+
description: "The ID of the review",
|
110
|
+
optional: false,
|
111
|
+
type: Integer)
|
112
|
+
]
|
113
|
+
end
|
114
|
+
|
115
|
+
def output
|
116
|
+
[
|
117
|
+
['GITHUB_GET_PULL_REVIEW_STATUS_CODE', 'The status code returned by the GitHub API'],
|
118
|
+
['GITHUB_GET_PULL_REVIEW_RESPONSE', 'The full response body returned by the GitHub API'],
|
119
|
+
['GITHUB_GET_PULL_REVIEW_JSON', 'The parsed JSON response returned by the GitHub API']
|
120
|
+
]
|
121
|
+
end
|
122
|
+
|
123
|
+
def return_value
|
124
|
+
"Returns a hash containing the status code, response body, and parsed JSON response from the GitHub API."
|
125
|
+
end
|
126
|
+
|
127
|
+
def authors
|
128
|
+
["crazymanish"]
|
129
|
+
end
|
130
|
+
|
131
|
+
def is_supported?(platform)
|
132
|
+
true
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
@@ -0,0 +1,181 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/github_api_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
module SharedValues
|
7
|
+
GITHUB_GET_PULL_REVIEW_COMMENTS_STATUS_CODE = :GITHUB_GET_PULL_REVIEW_COMMENTS_STATUS_CODE
|
8
|
+
GITHUB_GET_PULL_REVIEW_COMMENTS_RESPONSE = :GITHUB_GET_PULL_REVIEW_COMMENTS_RESPONSE
|
9
|
+
GITHUB_GET_PULL_REVIEW_COMMENTS_JSON = :GITHUB_GET_PULL_REVIEW_COMMENTS_JSON
|
10
|
+
end
|
11
|
+
|
12
|
+
class GithubGetPullReviewCommentsAction < Action
|
13
|
+
class << self
|
14
|
+
def run(params)
|
15
|
+
require 'json'
|
16
|
+
|
17
|
+
# Prepare API call parameters
|
18
|
+
server_url = params[:server_url]
|
19
|
+
api_token = params[:api_token]
|
20
|
+
repo_owner = params[:repo_owner]
|
21
|
+
repo_name = params[:repo_name]
|
22
|
+
pull_number = params[:pull_number]
|
23
|
+
review_id = params[:review_id]
|
24
|
+
per_page = params[:per_page]
|
25
|
+
page = params[:page]
|
26
|
+
|
27
|
+
# Build query parameters
|
28
|
+
query_params = {}
|
29
|
+
query_params[:per_page] = per_page if per_page
|
30
|
+
query_params[:page] = page if page
|
31
|
+
|
32
|
+
# Build the path
|
33
|
+
path = "/repos/#{repo_owner}/#{repo_name}/pulls/#{pull_number}/reviews/#{review_id}/comments"
|
34
|
+
|
35
|
+
UI.message("Getting comments for review ##{review_id} on pull request ##{pull_number} from #{repo_owner}/#{repo_name}")
|
36
|
+
response = Helper::GithubApiHelper.github_api_request(
|
37
|
+
token: api_token,
|
38
|
+
path: path,
|
39
|
+
params: query_params.empty? ? nil : query_params,
|
40
|
+
method: :get,
|
41
|
+
server_url: server_url
|
42
|
+
)
|
43
|
+
|
44
|
+
status_code = response[:status]
|
45
|
+
json_response = response[:json]
|
46
|
+
result = {
|
47
|
+
status: status_code,
|
48
|
+
body: response[:body],
|
49
|
+
json: json_response
|
50
|
+
}
|
51
|
+
|
52
|
+
if status_code.between?(200, 299)
|
53
|
+
comment_count = json_response.is_a?(Array) ? json_response.count : 0
|
54
|
+
UI.success("Successfully retrieved #{comment_count} comments for review ##{review_id} on pull request ##{pull_number}")
|
55
|
+
else
|
56
|
+
UI.error("Error getting review comments: #{status_code}")
|
57
|
+
UI.error(response[:body])
|
58
|
+
UI.user_error!("GitHub API returned #{status_code}: #{response[:body]}")
|
59
|
+
return nil
|
60
|
+
end
|
61
|
+
|
62
|
+
# Store the results in shared values
|
63
|
+
Actions.lane_context[SharedValues::GITHUB_GET_PULL_REVIEW_COMMENTS_STATUS_CODE] = status_code
|
64
|
+
Actions.lane_context[SharedValues::GITHUB_GET_PULL_REVIEW_COMMENTS_RESPONSE] = response[:body]
|
65
|
+
Actions.lane_context[SharedValues::GITHUB_GET_PULL_REVIEW_COMMENTS_JSON] = json_response
|
66
|
+
|
67
|
+
return result
|
68
|
+
end
|
69
|
+
|
70
|
+
#####################################################
|
71
|
+
# @!group Documentation
|
72
|
+
#####################################################
|
73
|
+
|
74
|
+
def description
|
75
|
+
"Get comments for a pull request review"
|
76
|
+
end
|
77
|
+
|
78
|
+
def details
|
79
|
+
[
|
80
|
+
"Lists all comments for a specific pull request review.",
|
81
|
+
"You must provide your GitHub Personal token (get one from https://github.com/settings/tokens/new).",
|
82
|
+
"API Documentation: https://docs.github.com/en/rest/pulls/reviews#get-comments-for-a-pull-request-review"
|
83
|
+
].join("\n")
|
84
|
+
end
|
85
|
+
|
86
|
+
def available_options
|
87
|
+
[
|
88
|
+
FastlaneCore::ConfigItem.new(key: :api_token,
|
89
|
+
env_name: "GITHUB_API_TOKEN",
|
90
|
+
description: "GitHub API token",
|
91
|
+
optional: false,
|
92
|
+
sensitive: true,
|
93
|
+
code_gen_sensitive: true,
|
94
|
+
default_value: ENV["GITHUB_API_TOKEN"],
|
95
|
+
verify_block: proc do |value|
|
96
|
+
UI.user_error!("No GitHub API token given, pass using `api_token: 'token'`") if value.to_s.empty?
|
97
|
+
end),
|
98
|
+
FastlaneCore::ConfigItem.new(key: :server_url,
|
99
|
+
env_name: "GITHUB_API_SERVER_URL",
|
100
|
+
description: "GitHub API server URL",
|
101
|
+
optional: true,
|
102
|
+
default_value: "https://api.github.com"),
|
103
|
+
FastlaneCore::ConfigItem.new(key: :repo_owner,
|
104
|
+
env_name: "GITHUB_API_REPO_OWNER",
|
105
|
+
description: "Owner of the repository",
|
106
|
+
optional: false),
|
107
|
+
FastlaneCore::ConfigItem.new(key: :repo_name,
|
108
|
+
env_name: "GITHUB_API_REPO_NAME",
|
109
|
+
description: "Name of the repository",
|
110
|
+
optional: false),
|
111
|
+
FastlaneCore::ConfigItem.new(key: :pull_number,
|
112
|
+
env_name: "GITHUB_API_PULL_NUMBER",
|
113
|
+
description: "The number of the pull request",
|
114
|
+
optional: false,
|
115
|
+
type: Integer),
|
116
|
+
FastlaneCore::ConfigItem.new(key: :review_id,
|
117
|
+
env_name: "GITHUB_API_REVIEW_ID",
|
118
|
+
description: "The ID of the review",
|
119
|
+
optional: false,
|
120
|
+
type: Integer),
|
121
|
+
FastlaneCore::ConfigItem.new(key: :per_page,
|
122
|
+
env_name: "GITHUB_API_PER_PAGE",
|
123
|
+
description: "Results per page (max 100)",
|
124
|
+
optional: true,
|
125
|
+
type: Integer),
|
126
|
+
FastlaneCore::ConfigItem.new(key: :page,
|
127
|
+
env_name: "GITHUB_API_PAGE",
|
128
|
+
description: "Page number of the results to fetch",
|
129
|
+
optional: true,
|
130
|
+
type: Integer)
|
131
|
+
]
|
132
|
+
end
|
133
|
+
|
134
|
+
def output
|
135
|
+
[
|
136
|
+
['GITHUB_GET_PULL_REVIEW_COMMENTS_STATUS_CODE', 'The status code returned by the GitHub API'],
|
137
|
+
['GITHUB_GET_PULL_REVIEW_COMMENTS_RESPONSE', 'The full response body returned by the GitHub API'],
|
138
|
+
['GITHUB_GET_PULL_REVIEW_COMMENTS_JSON', 'The parsed JSON response returned by the GitHub API']
|
139
|
+
]
|
140
|
+
end
|
141
|
+
|
142
|
+
def return_value
|
143
|
+
"Returns a hash containing the status code, response body, and parsed JSON response from the GitHub API."
|
144
|
+
end
|
145
|
+
|
146
|
+
def authors
|
147
|
+
["crazymanish"]
|
148
|
+
end
|
149
|
+
|
150
|
+
def is_supported?(platform)
|
151
|
+
true
|
152
|
+
end
|
153
|
+
|
154
|
+
def example_code
|
155
|
+
[
|
156
|
+
'github_get_pull_review_comments(
|
157
|
+
repo_owner: "octocat",
|
158
|
+
repo_name: "Hello-World",
|
159
|
+
pull_number: 42,
|
160
|
+
review_id: 80
|
161
|
+
)',
|
162
|
+
'comments = github_get_pull_review_comments(
|
163
|
+
repo_owner: "octocat",
|
164
|
+
repo_name: "Hello-World",
|
165
|
+
pull_number: 42,
|
166
|
+
review_id: 80,
|
167
|
+
per_page: 10,
|
168
|
+
page: 1
|
169
|
+
)
|
170
|
+
|
171
|
+
comments[:json].each do |comment|
|
172
|
+
puts "Comment by #{comment["user"]["login"]}: #{comment["body"]}"
|
173
|
+
puts "Path: #{comment["path"]}, Position: #{comment["position"]}"
|
174
|
+
puts "---"
|
175
|
+
end'
|
176
|
+
]
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
@@ -0,0 +1,186 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/github_api_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
module SharedValues
|
7
|
+
GITHUB_LIST_PULL_COMMENTS_ALL_STATUS_CODE = :GITHUB_LIST_PULL_COMMENTS_ALL_STATUS_CODE
|
8
|
+
GITHUB_LIST_PULL_COMMENTS_ALL_RESPONSE = :GITHUB_LIST_PULL_COMMENTS_ALL_RESPONSE
|
9
|
+
GITHUB_LIST_PULL_COMMENTS_ALL_JSON = :GITHUB_LIST_PULL_COMMENTS_ALL_JSON
|
10
|
+
end
|
11
|
+
|
12
|
+
class GithubListAllPullCommentsAction < Action
|
13
|
+
class << self
|
14
|
+
def run(params)
|
15
|
+
require 'json'
|
16
|
+
|
17
|
+
# Prepare API call parameters
|
18
|
+
server_url = params[:server_url]
|
19
|
+
api_token = params[:api_token]
|
20
|
+
repo_owner = params[:repo_owner]
|
21
|
+
repo_name = params[:repo_name]
|
22
|
+
|
23
|
+
# Build the path
|
24
|
+
path = "/repos/#{repo_owner}/#{repo_name}/pulls/comments"
|
25
|
+
|
26
|
+
# Build query parameters
|
27
|
+
query_params = {}
|
28
|
+
query_params[:sort] = params[:sort] if params[:sort]
|
29
|
+
query_params[:direction] = params[:direction] if params[:direction]
|
30
|
+
query_params[:since] = params[:since] if params[:since]
|
31
|
+
query_params[:per_page] = params[:per_page] if params[:per_page]
|
32
|
+
query_params[:page] = params[:page] if params[:page]
|
33
|
+
|
34
|
+
UI.message("Listing all pull request comments in #{repo_owner}/#{repo_name}")
|
35
|
+
response = Helper::GithubApiHelper.github_api_request(
|
36
|
+
token: api_token,
|
37
|
+
path: path,
|
38
|
+
params: query_params,
|
39
|
+
method: :get,
|
40
|
+
server_url: server_url
|
41
|
+
)
|
42
|
+
|
43
|
+
status_code = response[:status]
|
44
|
+
json_response = response[:json]
|
45
|
+
result = {
|
46
|
+
status: status_code,
|
47
|
+
body: response[:body],
|
48
|
+
json: json_response
|
49
|
+
}
|
50
|
+
|
51
|
+
if status_code.between?(200, 299)
|
52
|
+
comment_count = json_response.count
|
53
|
+
UI.success("Successfully retrieved #{comment_count} pull request comments")
|
54
|
+
else
|
55
|
+
UI.error("Error listing pull request comments: #{status_code}")
|
56
|
+
UI.error(response[:body])
|
57
|
+
UI.user_error!("GitHub API returned #{status_code}: #{response[:body]}")
|
58
|
+
return nil
|
59
|
+
end
|
60
|
+
|
61
|
+
# Store the results in shared values
|
62
|
+
Actions.lane_context[SharedValues::GITHUB_LIST_PULL_COMMENTS_ALL_STATUS_CODE] = status_code
|
63
|
+
Actions.lane_context[SharedValues::GITHUB_LIST_PULL_COMMENTS_ALL_RESPONSE] = response[:body]
|
64
|
+
Actions.lane_context[SharedValues::GITHUB_LIST_PULL_COMMENTS_ALL_JSON] = json_response
|
65
|
+
|
66
|
+
return result
|
67
|
+
end
|
68
|
+
|
69
|
+
#####################################################
|
70
|
+
# @!group Documentation
|
71
|
+
#####################################################
|
72
|
+
|
73
|
+
def description
|
74
|
+
"Lists review comments in a repository"
|
75
|
+
end
|
76
|
+
|
77
|
+
def details
|
78
|
+
[
|
79
|
+
"Lists all review comments on all pull requests in a repository with filtering options.",
|
80
|
+
"You must provide your GitHub Personal token (get one from https://github.com/settings/tokens/new).",
|
81
|
+
"API Documentation: https://docs.github.com/en/rest/pulls/comments#list-review-comments-in-a-repository"
|
82
|
+
].join("\n")
|
83
|
+
end
|
84
|
+
|
85
|
+
def available_options
|
86
|
+
[
|
87
|
+
FastlaneCore::ConfigItem.new(key: :api_token,
|
88
|
+
env_name: "GITHUB_API_TOKEN",
|
89
|
+
description: "GitHub API token",
|
90
|
+
optional: false,
|
91
|
+
sensitive: true,
|
92
|
+
code_gen_sensitive: true,
|
93
|
+
default_value: ENV["GITHUB_API_TOKEN"],
|
94
|
+
verify_block: proc do |value|
|
95
|
+
UI.user_error!("No GitHub API token given, pass using `api_token: 'token'`") if value.to_s.empty?
|
96
|
+
end),
|
97
|
+
FastlaneCore::ConfigItem.new(key: :server_url,
|
98
|
+
env_name: "GITHUB_API_SERVER_URL",
|
99
|
+
description: "GitHub API server URL",
|
100
|
+
optional: true,
|
101
|
+
default_value: "https://api.github.com"),
|
102
|
+
FastlaneCore::ConfigItem.new(key: :repo_owner,
|
103
|
+
env_name: "GITHUB_API_REPO_OWNER",
|
104
|
+
description: "Owner of the repository",
|
105
|
+
optional: false),
|
106
|
+
FastlaneCore::ConfigItem.new(key: :repo_name,
|
107
|
+
env_name: "GITHUB_API_REPO_NAME",
|
108
|
+
description: "Name of the repository",
|
109
|
+
optional: false),
|
110
|
+
FastlaneCore::ConfigItem.new(key: :sort,
|
111
|
+
env_name: "GITHUB_API_PR_COMMENTS_SORT",
|
112
|
+
description: "What to sort results by: created, updated",
|
113
|
+
optional: true,
|
114
|
+
type: String,
|
115
|
+
verify_block: proc do |value|
|
116
|
+
UI.user_error!("Sort must be one of: created, updated") unless ["created", "updated"].include?(value)
|
117
|
+
end),
|
118
|
+
FastlaneCore::ConfigItem.new(key: :direction,
|
119
|
+
env_name: "GITHUB_API_PR_COMMENTS_DIRECTION",
|
120
|
+
description: "The direction of the sort: asc or desc",
|
121
|
+
optional: true,
|
122
|
+
type: String,
|
123
|
+
verify_block: proc do |value|
|
124
|
+
UI.user_error!("Direction must be one of: asc, desc") unless ["asc", "desc"].include?(value)
|
125
|
+
end),
|
126
|
+
FastlaneCore::ConfigItem.new(key: :since,
|
127
|
+
env_name: "GITHUB_API_PR_COMMENTS_SINCE",
|
128
|
+
description: "Only comments updated at or after this time are returned (ISO 8601 format)",
|
129
|
+
optional: true,
|
130
|
+
type: String),
|
131
|
+
FastlaneCore::ConfigItem.new(key: :per_page,
|
132
|
+
env_name: "GITHUB_API_PR_COMMENTS_PER_PAGE",
|
133
|
+
description: "Results per page (max 100)",
|
134
|
+
optional: true,
|
135
|
+
type: Integer),
|
136
|
+
FastlaneCore::ConfigItem.new(key: :page,
|
137
|
+
env_name: "GITHUB_API_PR_COMMENTS_PAGE",
|
138
|
+
description: "Page number of the results to fetch",
|
139
|
+
optional: true,
|
140
|
+
type: Integer)
|
141
|
+
]
|
142
|
+
end
|
143
|
+
|
144
|
+
def output
|
145
|
+
[
|
146
|
+
['GITHUB_LIST_PULL_COMMENTS_ALL_STATUS_CODE', 'The status code returned by the GitHub API'],
|
147
|
+
['GITHUB_LIST_PULL_COMMENTS_ALL_RESPONSE', 'The full response body returned by the GitHub API'],
|
148
|
+
['GITHUB_LIST_PULL_COMMENTS_ALL_JSON', 'The parsed JSON response returned by the GitHub API']
|
149
|
+
]
|
150
|
+
end
|
151
|
+
|
152
|
+
def return_value
|
153
|
+
"Returns a hash containing the status code, response body, and parsed JSON response from the GitHub API."
|
154
|
+
end
|
155
|
+
|
156
|
+
def authors
|
157
|
+
["crazymanish"]
|
158
|
+
end
|
159
|
+
|
160
|
+
def is_supported?(platform)
|
161
|
+
true
|
162
|
+
end
|
163
|
+
|
164
|
+
def example_code
|
165
|
+
[
|
166
|
+
'github_list_all_pull_comments(
|
167
|
+
repo_owner: "octocat",
|
168
|
+
repo_name: "Hello-World",
|
169
|
+
sort: "created",
|
170
|
+
direction: "desc"
|
171
|
+
)',
|
172
|
+
'comments = github_list_all_pull_comments(
|
173
|
+
repo_owner: "octocat",
|
174
|
+
repo_name: "Hello-World",
|
175
|
+
since: "2022-01-01T00:00:00Z"
|
176
|
+
)
|
177
|
+
|
178
|
+
comments[:json].each do |comment|
|
179
|
+
puts "Comment ID: #{comment["id"]}, on PR: #{comment["pull_request_url"]}"
|
180
|
+
end'
|
181
|
+
]
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
@@ -0,0 +1,183 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/github_api_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
module SharedValues
|
7
|
+
GITHUB_LIST_COMMIT_COMMENT_REACTIONS_STATUS_CODE = :GITHUB_LIST_COMMIT_COMMENT_REACTIONS_STATUS_CODE
|
8
|
+
GITHUB_LIST_COMMIT_COMMENT_REACTIONS_RESPONSE = :GITHUB_LIST_COMMIT_COMMENT_REACTIONS_RESPONSE
|
9
|
+
GITHUB_LIST_COMMIT_COMMENT_REACTIONS_JSON = :GITHUB_LIST_COMMIT_COMMENT_REACTIONS_JSON
|
10
|
+
end
|
11
|
+
|
12
|
+
class GithubListCommitCommentReactionsAction < Action
|
13
|
+
class << self
|
14
|
+
def run(params)
|
15
|
+
require 'json'
|
16
|
+
|
17
|
+
# Prepare API call parameters
|
18
|
+
server_url = params[:server_url]
|
19
|
+
api_token = params[:api_token]
|
20
|
+
repo_owner = params[:repo_owner]
|
21
|
+
repo_name = params[:repo_name]
|
22
|
+
comment_id = params[:comment_id]
|
23
|
+
content = params[:content]
|
24
|
+
per_page = params[:per_page]
|
25
|
+
page = params[:page]
|
26
|
+
|
27
|
+
# Build query parameters
|
28
|
+
query_params = {}
|
29
|
+
query_params[:content] = content if content
|
30
|
+
query_params[:per_page] = per_page if per_page
|
31
|
+
query_params[:page] = page if page
|
32
|
+
|
33
|
+
# Build the path
|
34
|
+
path = "/repos/#{repo_owner}/#{repo_name}/comments/#{comment_id}/reactions"
|
35
|
+
|
36
|
+
UI.message("Listing reactions for commit comment ##{comment_id} in #{repo_owner}/#{repo_name}")
|
37
|
+
response = Helper::GithubApiHelper.github_api_request(
|
38
|
+
token: api_token,
|
39
|
+
path: path,
|
40
|
+
params: query_params.empty? ? nil : query_params,
|
41
|
+
method: :get,
|
42
|
+
server_url: server_url,
|
43
|
+
headers: { 'Accept' => 'application/vnd.github.squirrel-girl-preview+json' }
|
44
|
+
)
|
45
|
+
|
46
|
+
status_code = response[:status]
|
47
|
+
json_response = response[:json]
|
48
|
+
result = {
|
49
|
+
status: status_code,
|
50
|
+
body: response[:body],
|
51
|
+
json: json_response
|
52
|
+
}
|
53
|
+
|
54
|
+
if status_code.between?(200, 299)
|
55
|
+
reaction_count = json_response.is_a?(Array) ? json_response.count : 0
|
56
|
+
UI.success("Successfully retrieved #{reaction_count} reactions for commit comment ##{comment_id}")
|
57
|
+
else
|
58
|
+
UI.error("Error listing commit comment reactions: #{status_code}")
|
59
|
+
UI.error(response[:body])
|
60
|
+
UI.user_error!("GitHub API returned #{status_code}: #{response[:body]}")
|
61
|
+
return nil
|
62
|
+
end
|
63
|
+
|
64
|
+
# Store the results in shared values
|
65
|
+
Actions.lane_context[SharedValues::GITHUB_LIST_COMMIT_COMMENT_REACTIONS_STATUS_CODE] = status_code
|
66
|
+
Actions.lane_context[SharedValues::GITHUB_LIST_COMMIT_COMMENT_REACTIONS_RESPONSE] = response[:body]
|
67
|
+
Actions.lane_context[SharedValues::GITHUB_LIST_COMMIT_COMMENT_REACTIONS_JSON] = json_response
|
68
|
+
|
69
|
+
return result
|
70
|
+
end
|
71
|
+
|
72
|
+
#####################################################
|
73
|
+
# @!group Documentation
|
74
|
+
#####################################################
|
75
|
+
|
76
|
+
def description
|
77
|
+
"List reactions for a commit comment"
|
78
|
+
end
|
79
|
+
|
80
|
+
def details
|
81
|
+
[
|
82
|
+
"Lists all reactions for a commit comment.",
|
83
|
+
"You must provide your GitHub Personal token (get one from https://github.com/settings/tokens/new).",
|
84
|
+
"API Documentation: https://docs.github.com/en/rest/reactions/reactions#list-reactions-for-a-commit-comment"
|
85
|
+
].join("\n")
|
86
|
+
end
|
87
|
+
|
88
|
+
def available_options
|
89
|
+
[
|
90
|
+
FastlaneCore::ConfigItem.new(key: :api_token,
|
91
|
+
env_name: "GITHUB_API_TOKEN",
|
92
|
+
description: "GitHub API token",
|
93
|
+
optional: false,
|
94
|
+
sensitive: true,
|
95
|
+
code_gen_sensitive: true,
|
96
|
+
default_value: ENV["GITHUB_API_TOKEN"],
|
97
|
+
verify_block: proc do |value|
|
98
|
+
UI.user_error!("No GitHub API token given, pass using `api_token: 'token'`") if value.to_s.empty?
|
99
|
+
end),
|
100
|
+
FastlaneCore::ConfigItem.new(key: :server_url,
|
101
|
+
env_name: "GITHUB_API_SERVER_URL",
|
102
|
+
description: "GitHub API server URL",
|
103
|
+
optional: true,
|
104
|
+
default_value: "https://api.github.com"),
|
105
|
+
FastlaneCore::ConfigItem.new(key: :repo_owner,
|
106
|
+
env_name: "GITHUB_API_REPO_OWNER",
|
107
|
+
description: "Owner of the repository",
|
108
|
+
optional: false),
|
109
|
+
FastlaneCore::ConfigItem.new(key: :repo_name,
|
110
|
+
env_name: "GITHUB_API_REPO_NAME",
|
111
|
+
description: "Name of the repository",
|
112
|
+
optional: false),
|
113
|
+
FastlaneCore::ConfigItem.new(key: :comment_id,
|
114
|
+
env_name: "GITHUB_API_COMMENT_ID",
|
115
|
+
description: "The ID of the commit comment",
|
116
|
+
optional: false,
|
117
|
+
type: Integer),
|
118
|
+
FastlaneCore::ConfigItem.new(key: :content,
|
119
|
+
env_name: "GITHUB_API_REACTION_CONTENT",
|
120
|
+
description: "Filter reactions by content (e.g., +1, -1, laugh, confused, heart, hooray, rocket, eyes)",
|
121
|
+
optional: true,
|
122
|
+
type: String),
|
123
|
+
FastlaneCore::ConfigItem.new(key: :per_page,
|
124
|
+
env_name: "GITHUB_API_PER_PAGE",
|
125
|
+
description: "Results per page (max 100)",
|
126
|
+
optional: true,
|
127
|
+
type: Integer),
|
128
|
+
FastlaneCore::ConfigItem.new(key: :page,
|
129
|
+
env_name: "GITHUB_API_PAGE",
|
130
|
+
description: "Page number of the results to fetch",
|
131
|
+
optional: true,
|
132
|
+
type: Integer)
|
133
|
+
]
|
134
|
+
end
|
135
|
+
|
136
|
+
def output
|
137
|
+
[
|
138
|
+
['GITHUB_LIST_COMMIT_COMMENT_REACTIONS_STATUS_CODE', 'The status code returned by the GitHub API'],
|
139
|
+
['GITHUB_LIST_COMMIT_COMMENT_REACTIONS_RESPONSE', 'The full response body returned by the GitHub API'],
|
140
|
+
['GITHUB_LIST_COMMIT_COMMENT_REACTIONS_JSON', 'The parsed JSON response returned by the GitHub API']
|
141
|
+
]
|
142
|
+
end
|
143
|
+
|
144
|
+
def return_value
|
145
|
+
"Returns a hash containing the status code, response body, and parsed JSON response from the GitHub API."
|
146
|
+
end
|
147
|
+
|
148
|
+
def authors
|
149
|
+
["crazymanish"]
|
150
|
+
end
|
151
|
+
|
152
|
+
def is_supported?(platform)
|
153
|
+
true
|
154
|
+
end
|
155
|
+
|
156
|
+
def example_code
|
157
|
+
[
|
158
|
+
'github_list_commit_comment_reactions(
|
159
|
+
repo_owner: "octocat",
|
160
|
+
repo_name: "Hello-World",
|
161
|
+
comment_id: 123
|
162
|
+
)',
|
163
|
+
'reactions = github_list_commit_comment_reactions(
|
164
|
+
repo_owner: "octocat",
|
165
|
+
repo_name: "Hello-World",
|
166
|
+
comment_id: 123,
|
167
|
+
content: "+1",
|
168
|
+
per_page: 20,
|
169
|
+
page: 1
|
170
|
+
)
|
171
|
+
|
172
|
+
reactions[:json].each do |reaction|
|
173
|
+
puts "Reaction: #{reaction["content"]}"
|
174
|
+
puts "User: #{reaction["user"]["login"]}"
|
175
|
+
puts "Created at: #{reaction["created_at"]}"
|
176
|
+
puts "---"
|
177
|
+
end'
|
178
|
+
]
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|