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,205 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/github_api_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
module SharedValues
|
7
|
+
GITHUB_LIST_MILESTONES_RESPONSE = :GITHUB_LIST_MILESTONES_RESPONSE
|
8
|
+
GITHUB_LIST_MILESTONES_JSON = :GITHUB_LIST_MILESTONES_JSON
|
9
|
+
GITHUB_LIST_MILESTONES_STATUS_CODE = :GITHUB_LIST_MILESTONES_STATUS_CODE
|
10
|
+
end
|
11
|
+
|
12
|
+
class GithubListMilestonesAction < Action
|
13
|
+
class << self
|
14
|
+
def run(params)
|
15
|
+
token = params[:api_token]
|
16
|
+
repo_owner = params[:repo_owner]
|
17
|
+
repo_name = params[:repo_name]
|
18
|
+
server_url = params[:server_url]
|
19
|
+
|
20
|
+
# Validate parameters (additional validation beyond what's in ConfigItem)
|
21
|
+
UI.user_error!("No repository owner provided, pass using `repo_owner: 'owner'`") if repo_owner.to_s.empty?
|
22
|
+
UI.user_error!("No repository name provided, pass using `repo_name: 'name'`") if repo_name.to_s.empty?
|
23
|
+
|
24
|
+
# Prepare request parameters
|
25
|
+
path = "/repos/#{repo_owner}/#{repo_name}/milestones"
|
26
|
+
|
27
|
+
# Build query parameters
|
28
|
+
query_params = {}
|
29
|
+
query_params[:state] = params[:state] if params[:state]
|
30
|
+
query_params[:sort] = params[:sort] if params[:sort]
|
31
|
+
query_params[:direction] = params[:direction] if params[:direction]
|
32
|
+
query_params[:per_page] = params[:per_page] if params[:per_page]
|
33
|
+
query_params[:page] = params[:page] if params[:page]
|
34
|
+
|
35
|
+
# Make the request
|
36
|
+
UI.message("Fetching milestones for #{repo_owner}/#{repo_name}")
|
37
|
+
response = Helper::GithubApiHelper.github_api_request(
|
38
|
+
token: token,
|
39
|
+
path: path,
|
40
|
+
params: query_params,
|
41
|
+
method: :get,
|
42
|
+
server_url: server_url
|
43
|
+
)
|
44
|
+
|
45
|
+
status_code = response.key?('status') ? response['status'] : nil
|
46
|
+
result = {
|
47
|
+
status: status_code,
|
48
|
+
body: response,
|
49
|
+
json: response
|
50
|
+
}
|
51
|
+
|
52
|
+
if response.key?('error')
|
53
|
+
UI.error("GitHub responded with an error: #{response['error']}")
|
54
|
+
UI.user_error!("GitHub API error: #{response['error']}")
|
55
|
+
return nil
|
56
|
+
end
|
57
|
+
|
58
|
+
if response.is_a?(Hash) && response['message'] && status_code && status_code >= 400
|
59
|
+
UI.error("GitHub API error: #{response['message']}")
|
60
|
+
UI.user_error!("GitHub API error: #{response['message']} (Status code: #{status_code})")
|
61
|
+
return nil
|
62
|
+
end
|
63
|
+
|
64
|
+
# Print milestone info
|
65
|
+
if response.is_a?(Array)
|
66
|
+
UI.success("Successfully fetched #{response.count} milestones from #{repo_owner}/#{repo_name}")
|
67
|
+
else
|
68
|
+
UI.success("Successfully fetched milestones from #{repo_owner}/#{repo_name}")
|
69
|
+
end
|
70
|
+
|
71
|
+
# Set the shared values
|
72
|
+
Actions.lane_context[SharedValues::GITHUB_LIST_MILESTONES_STATUS_CODE] = status_code
|
73
|
+
Actions.lane_context[SharedValues::GITHUB_LIST_MILESTONES_RESPONSE] = response
|
74
|
+
Actions.lane_context[SharedValues::GITHUB_LIST_MILESTONES_JSON] = response
|
75
|
+
|
76
|
+
return result
|
77
|
+
end
|
78
|
+
|
79
|
+
#####################################################
|
80
|
+
# @!group Documentation
|
81
|
+
#####################################################
|
82
|
+
|
83
|
+
def description
|
84
|
+
"Lists milestones in a GitHub repository"
|
85
|
+
end
|
86
|
+
|
87
|
+
def details
|
88
|
+
[
|
89
|
+
"This action fetches a list of milestones from a GitHub repository, with various filtering options.",
|
90
|
+
"It requires a valid GitHub API token with appropriate permissions.",
|
91
|
+
"Documentation: [https://docs.github.com/en/rest/issues/milestones](https://docs.github.com/en/rest/issues/milestones#list-milestones)"
|
92
|
+
].join("\n")
|
93
|
+
end
|
94
|
+
|
95
|
+
def available_options
|
96
|
+
[
|
97
|
+
FastlaneCore::ConfigItem.new(key: :api_token,
|
98
|
+
env_name: "GITHUB_API_TOKEN",
|
99
|
+
description: "GitHub API token with repo permissions",
|
100
|
+
optional: false,
|
101
|
+
type: String,
|
102
|
+
sensitive: true,
|
103
|
+
code_gen_sensitive: true,
|
104
|
+
default_value: ENV["GITHUB_API_TOKEN"],
|
105
|
+
verify_block: proc do |value|
|
106
|
+
UI.user_error!("No GitHub API token given, pass using `api_token: 'token'`") if value.to_s.empty?
|
107
|
+
end),
|
108
|
+
FastlaneCore::ConfigItem.new(key: :server_url,
|
109
|
+
env_name: "GITHUB_API_SERVER_URL",
|
110
|
+
description: "GitHub API server URL",
|
111
|
+
optional: true,
|
112
|
+
default_value: "https://api.github.com"),
|
113
|
+
FastlaneCore::ConfigItem.new(key: :repo_owner,
|
114
|
+
env_name: "GITHUB_API_REPO_OWNER",
|
115
|
+
description: "Repository owner (organization or username)",
|
116
|
+
optional: false,
|
117
|
+
type: String,
|
118
|
+
verify_block: proc do |value|
|
119
|
+
UI.user_error!("No repository owner provided, pass using `repo_owner: 'owner'`") if value.to_s.empty?
|
120
|
+
end),
|
121
|
+
FastlaneCore::ConfigItem.new(key: :repo_name,
|
122
|
+
env_name: "GITHUB_API_REPO_NAME",
|
123
|
+
description: "Repository name",
|
124
|
+
optional: false,
|
125
|
+
type: String,
|
126
|
+
verify_block: proc do |value|
|
127
|
+
UI.user_error!("No repository name provided, pass using `repo_name: 'name'`") if value.to_s.empty?
|
128
|
+
end),
|
129
|
+
FastlaneCore::ConfigItem.new(key: :state,
|
130
|
+
description: "State of the milestones (open, closed, all)",
|
131
|
+
optional: true,
|
132
|
+
default_value: "open",
|
133
|
+
type: String),
|
134
|
+
FastlaneCore::ConfigItem.new(key: :sort,
|
135
|
+
description: "Sort by (due_on, completeness)",
|
136
|
+
optional: true,
|
137
|
+
default_value: "due_on",
|
138
|
+
type: String),
|
139
|
+
FastlaneCore::ConfigItem.new(key: :direction,
|
140
|
+
description: "Sort direction (asc or desc)",
|
141
|
+
optional: true,
|
142
|
+
default_value: "asc",
|
143
|
+
type: String),
|
144
|
+
FastlaneCore::ConfigItem.new(key: :per_page,
|
145
|
+
description: "Results per page (max 100)",
|
146
|
+
optional: true,
|
147
|
+
default_value: 30,
|
148
|
+
type: Integer),
|
149
|
+
FastlaneCore::ConfigItem.new(key: :page,
|
150
|
+
description: "Page number of the results",
|
151
|
+
optional: true,
|
152
|
+
default_value: 1,
|
153
|
+
type: Integer)
|
154
|
+
]
|
155
|
+
end
|
156
|
+
|
157
|
+
def output
|
158
|
+
[
|
159
|
+
['GITHUB_LIST_MILESTONES_STATUS_CODE', 'The status code returned from the GitHub API'],
|
160
|
+
['GITHUB_LIST_MILESTONES_RESPONSE', 'The full response from the GitHub API'],
|
161
|
+
['GITHUB_LIST_MILESTONES_JSON', 'The JSON data returned from the GitHub API']
|
162
|
+
]
|
163
|
+
end
|
164
|
+
|
165
|
+
def return_value
|
166
|
+
"A hash including the HTTP status code (:status), the response body (:body), and the parsed JSON (:json)."
|
167
|
+
end
|
168
|
+
|
169
|
+
def authors
|
170
|
+
["crazymanish"]
|
171
|
+
end
|
172
|
+
|
173
|
+
def example_code
|
174
|
+
[
|
175
|
+
'github_list_milestones(
|
176
|
+
api_token: ENV["GITHUB_API_TOKEN"],
|
177
|
+
repo_owner: "fastlane",
|
178
|
+
repo_name: "fastlane",
|
179
|
+
state: "open",
|
180
|
+
sort: "due_on",
|
181
|
+
direction: "asc"
|
182
|
+
)',
|
183
|
+
'# You can also access the response data
|
184
|
+
result = github_list_milestones(
|
185
|
+
api_token: ENV["GITHUB_API_TOKEN"],
|
186
|
+
repo_owner: "fastlane",
|
187
|
+
repo_name: "fastlane"
|
188
|
+
)
|
189
|
+
result[:json].each do |milestone|
|
190
|
+
UI.message("Milestone: #{milestone["title"]}, due on: #{milestone["due_on"]}")
|
191
|
+
end'
|
192
|
+
]
|
193
|
+
end
|
194
|
+
|
195
|
+
def category
|
196
|
+
:source_control
|
197
|
+
end
|
198
|
+
|
199
|
+
def is_supported?(platform)
|
200
|
+
true
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
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_PULL_COMMENT_REACTIONS_STATUS_CODE = :GITHUB_LIST_PULL_COMMENT_REACTIONS_STATUS_CODE
|
8
|
+
GITHUB_LIST_PULL_COMMENT_REACTIONS_RESPONSE = :GITHUB_LIST_PULL_COMMENT_REACTIONS_RESPONSE
|
9
|
+
GITHUB_LIST_PULL_COMMENT_REACTIONS_JSON = :GITHUB_LIST_PULL_COMMENT_REACTIONS_JSON
|
10
|
+
end
|
11
|
+
|
12
|
+
class GithubListPullCommentReactionsAction < 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}/pulls/comments/#{comment_id}/reactions"
|
35
|
+
|
36
|
+
UI.message("Listing reactions for pull request review 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 pull request review comment ##{comment_id}")
|
57
|
+
else
|
58
|
+
UI.error("Error listing pull request review 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_PULL_COMMENT_REACTIONS_STATUS_CODE] = status_code
|
66
|
+
Actions.lane_context[SharedValues::GITHUB_LIST_PULL_COMMENT_REACTIONS_RESPONSE] = response[:body]
|
67
|
+
Actions.lane_context[SharedValues::GITHUB_LIST_PULL_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 pull request review comment"
|
78
|
+
end
|
79
|
+
|
80
|
+
def details
|
81
|
+
[
|
82
|
+
"Lists reactions for a pull request review 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-pull-request-review-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 pull request review 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_PULL_COMMENT_REACTIONS_STATUS_CODE', 'The status code returned by the GitHub API'],
|
139
|
+
['GITHUB_LIST_PULL_COMMENT_REACTIONS_RESPONSE', 'The full response body returned by the GitHub API'],
|
140
|
+
['GITHUB_LIST_PULL_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_pull_comment_reactions(
|
159
|
+
repo_owner: "octocat",
|
160
|
+
repo_name: "Hello-World",
|
161
|
+
comment_id: 123
|
162
|
+
)',
|
163
|
+
'reactions = github_list_pull_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
|
@@ -0,0 +1,203 @@
|
|
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_STATUS_CODE = :GITHUB_LIST_PULL_COMMENTS_STATUS_CODE
|
8
|
+
GITHUB_LIST_PULL_COMMENTS_RESPONSE = :GITHUB_LIST_PULL_COMMENTS_RESPONSE
|
9
|
+
GITHUB_LIST_PULL_COMMENTS_JSON = :GITHUB_LIST_PULL_COMMENTS_JSON
|
10
|
+
end
|
11
|
+
|
12
|
+
class GithubListPullCommentsAction < 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
|
+
sort = params[:sort]
|
24
|
+
direction = params[:direction]
|
25
|
+
since = params[:since]
|
26
|
+
per_page = params[:per_page]
|
27
|
+
page = params[:page]
|
28
|
+
|
29
|
+
# Build query parameters
|
30
|
+
query_params = {}
|
31
|
+
query_params[:sort] = sort if sort
|
32
|
+
query_params[:direction] = direction if direction
|
33
|
+
query_params[:since] = since if since
|
34
|
+
query_params[:per_page] = per_page if per_page
|
35
|
+
query_params[:page] = page if page
|
36
|
+
|
37
|
+
# Build the path
|
38
|
+
path = "/repos/#{repo_owner}/#{repo_name}/pulls/#{pull_number}/comments"
|
39
|
+
|
40
|
+
UI.message("Listing review comments on pull request ##{pull_number} from #{repo_owner}/#{repo_name}")
|
41
|
+
response = Helper::GithubApiHelper.github_api_request(
|
42
|
+
token: api_token,
|
43
|
+
path: path,
|
44
|
+
params: query_params.empty? ? nil : query_params,
|
45
|
+
method: :get,
|
46
|
+
server_url: server_url
|
47
|
+
)
|
48
|
+
|
49
|
+
status_code = response[:status]
|
50
|
+
json_response = response[:json]
|
51
|
+
result = {
|
52
|
+
status: status_code,
|
53
|
+
body: response[:body],
|
54
|
+
json: json_response
|
55
|
+
}
|
56
|
+
|
57
|
+
if status_code.between?(200, 299)
|
58
|
+
comment_count = json_response.is_a?(Array) ? json_response.count : 0
|
59
|
+
UI.success("Successfully retrieved #{comment_count} review comments for pull request ##{pull_number}")
|
60
|
+
else
|
61
|
+
UI.error("Error listing pull request comments: #{status_code}")
|
62
|
+
UI.error(response[:body])
|
63
|
+
UI.user_error!("GitHub API returned #{status_code}: #{response[:body]}")
|
64
|
+
return nil
|
65
|
+
end
|
66
|
+
|
67
|
+
# Store the results in shared values
|
68
|
+
Actions.lane_context[SharedValues::GITHUB_LIST_PULL_COMMENTS_STATUS_CODE] = status_code
|
69
|
+
Actions.lane_context[SharedValues::GITHUB_LIST_PULL_COMMENTS_RESPONSE] = response[:body]
|
70
|
+
Actions.lane_context[SharedValues::GITHUB_LIST_PULL_COMMENTS_JSON] = json_response
|
71
|
+
|
72
|
+
return result
|
73
|
+
end
|
74
|
+
|
75
|
+
#####################################################
|
76
|
+
# @!group Documentation
|
77
|
+
#####################################################
|
78
|
+
|
79
|
+
def description
|
80
|
+
"List review comments on a pull request"
|
81
|
+
end
|
82
|
+
|
83
|
+
def details
|
84
|
+
[
|
85
|
+
"Lists all review comments on a pull request.",
|
86
|
+
"You must provide your GitHub Personal token (get one from https://github.com/settings/tokens/new).",
|
87
|
+
"API Documentation: https://docs.github.com/en/rest/pulls/comments#list-review-comments-on-a-pull-request"
|
88
|
+
].join("\n")
|
89
|
+
end
|
90
|
+
|
91
|
+
def available_options
|
92
|
+
[
|
93
|
+
FastlaneCore::ConfigItem.new(key: :api_token,
|
94
|
+
env_name: "GITHUB_API_TOKEN",
|
95
|
+
description: "GitHub API token",
|
96
|
+
optional: false,
|
97
|
+
sensitive: true,
|
98
|
+
code_gen_sensitive: true,
|
99
|
+
default_value: ENV["GITHUB_API_TOKEN"],
|
100
|
+
verify_block: proc do |value|
|
101
|
+
UI.user_error!("No GitHub API token given, pass using `api_token: 'token'`") if value.to_s.empty?
|
102
|
+
end),
|
103
|
+
FastlaneCore::ConfigItem.new(key: :server_url,
|
104
|
+
env_name: "GITHUB_API_SERVER_URL",
|
105
|
+
description: "GitHub API server URL",
|
106
|
+
optional: true,
|
107
|
+
default_value: "https://api.github.com"),
|
108
|
+
FastlaneCore::ConfigItem.new(key: :repo_owner,
|
109
|
+
env_name: "GITHUB_API_REPO_OWNER",
|
110
|
+
description: "Owner of the repository",
|
111
|
+
optional: false),
|
112
|
+
FastlaneCore::ConfigItem.new(key: :repo_name,
|
113
|
+
env_name: "GITHUB_API_REPO_NAME",
|
114
|
+
description: "Name of the repository",
|
115
|
+
optional: false),
|
116
|
+
FastlaneCore::ConfigItem.new(key: :pull_number,
|
117
|
+
env_name: "GITHUB_API_PULL_NUMBER",
|
118
|
+
description: "The number of the pull request",
|
119
|
+
optional: false,
|
120
|
+
type: Integer),
|
121
|
+
FastlaneCore::ConfigItem.new(key: :sort,
|
122
|
+
env_name: "GITHUB_API_SORT",
|
123
|
+
description: "Sort direction (created, updated)",
|
124
|
+
optional: true,
|
125
|
+
type: String,
|
126
|
+
verify_block: proc do |value|
|
127
|
+
UI.user_error!("Sort must be either 'created' or 'updated'") unless ['created', 'updated'].include?(value)
|
128
|
+
end),
|
129
|
+
FastlaneCore::ConfigItem.new(key: :direction,
|
130
|
+
env_name: "GITHUB_API_DIRECTION",
|
131
|
+
description: "Sort direction (asc or desc)",
|
132
|
+
optional: true,
|
133
|
+
type: String,
|
134
|
+
verify_block: proc do |value|
|
135
|
+
UI.user_error!("Direction must be either 'asc' or 'desc'") unless ['asc', 'desc'].include?(value)
|
136
|
+
end),
|
137
|
+
FastlaneCore::ConfigItem.new(key: :since,
|
138
|
+
env_name: "GITHUB_API_SINCE",
|
139
|
+
description: "Only show comments updated at or after this time (ISO 8601 format)",
|
140
|
+
optional: true,
|
141
|
+
type: String),
|
142
|
+
FastlaneCore::ConfigItem.new(key: :per_page,
|
143
|
+
env_name: "GITHUB_API_PER_PAGE",
|
144
|
+
description: "Results per page (max 100)",
|
145
|
+
optional: true,
|
146
|
+
type: Integer),
|
147
|
+
FastlaneCore::ConfigItem.new(key: :page,
|
148
|
+
env_name: "GITHUB_API_PAGE",
|
149
|
+
description: "Page number of the results to fetch",
|
150
|
+
optional: true,
|
151
|
+
type: Integer)
|
152
|
+
]
|
153
|
+
end
|
154
|
+
|
155
|
+
def output
|
156
|
+
[
|
157
|
+
['GITHUB_LIST_PULL_COMMENTS_STATUS_CODE', 'The status code returned by the GitHub API'],
|
158
|
+
['GITHUB_LIST_PULL_COMMENTS_RESPONSE', 'The full response body returned by the GitHub API'],
|
159
|
+
['GITHUB_LIST_PULL_COMMENTS_JSON', 'The parsed JSON response returned by the GitHub API']
|
160
|
+
]
|
161
|
+
end
|
162
|
+
|
163
|
+
def return_value
|
164
|
+
"Returns a hash containing the status code, response body, and parsed JSON response from the GitHub API."
|
165
|
+
end
|
166
|
+
|
167
|
+
def authors
|
168
|
+
["crazymanish"]
|
169
|
+
end
|
170
|
+
|
171
|
+
def is_supported?(platform)
|
172
|
+
true
|
173
|
+
end
|
174
|
+
|
175
|
+
def example_code
|
176
|
+
[
|
177
|
+
'github_list_pull_comments(
|
178
|
+
repo_owner: "octocat",
|
179
|
+
repo_name: "Hello-World",
|
180
|
+
pull_number: 42
|
181
|
+
)',
|
182
|
+
'comments = github_list_pull_comments(
|
183
|
+
repo_owner: "octocat",
|
184
|
+
repo_name: "Hello-World",
|
185
|
+
pull_number: 42,
|
186
|
+
sort: "updated",
|
187
|
+
direction: "desc",
|
188
|
+
per_page: 20,
|
189
|
+
page: 1
|
190
|
+
)
|
191
|
+
|
192
|
+
comments[:json].each do |comment|
|
193
|
+
puts "Comment by #{comment["user"]["login"]}: #{comment["body"]}"
|
194
|
+
puts "Path: #{comment["path"]}, Position: #{comment["position"]}"
|
195
|
+
puts "Created at: #{comment["created_at"]}"
|
196
|
+
puts "---"
|
197
|
+
end'
|
198
|
+
]
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|