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,168 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/github_api_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
module SharedValues
|
7
|
+
GITHUB_DISMISS_PULL_REVIEW_STATUS_CODE = :GITHUB_DISMISS_PULL_REVIEW_STATUS_CODE
|
8
|
+
GITHUB_DISMISS_PULL_REVIEW_RESPONSE = :GITHUB_DISMISS_PULL_REVIEW_RESPONSE
|
9
|
+
GITHUB_DISMISS_PULL_REVIEW_JSON = :GITHUB_DISMISS_PULL_REVIEW_JSON
|
10
|
+
end
|
11
|
+
|
12
|
+
class GithubDismissPullReviewAction < 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
|
+
message = params[:message]
|
25
|
+
|
26
|
+
# Build the body for the request
|
27
|
+
body = { message: message }
|
28
|
+
|
29
|
+
# Build the path
|
30
|
+
path = "/repos/#{repo_owner}/#{repo_name}/pulls/#{pull_number}/reviews/#{review_id}/dismissals"
|
31
|
+
|
32
|
+
UI.message("Dismissing review ##{review_id} for pull request ##{pull_number} in #{repo_owner}/#{repo_name}")
|
33
|
+
response = Helper::GithubApiHelper.github_api_request(
|
34
|
+
token: api_token,
|
35
|
+
path: path,
|
36
|
+
params: body,
|
37
|
+
method: :put,
|
38
|
+
server_url: server_url
|
39
|
+
)
|
40
|
+
|
41
|
+
status_code = response[:status]
|
42
|
+
json_response = response[:json]
|
43
|
+
result = {
|
44
|
+
status: status_code,
|
45
|
+
body: response[:body],
|
46
|
+
json: json_response
|
47
|
+
}
|
48
|
+
|
49
|
+
if status_code.between?(200, 299)
|
50
|
+
UI.success("Successfully dismissed review ##{review_id} for pull request ##{pull_number}")
|
51
|
+
else
|
52
|
+
UI.error("Error dismissing review: #{status_code}")
|
53
|
+
UI.error(response[:body])
|
54
|
+
UI.user_error!("GitHub API returned #{status_code}: #{response[:body]}")
|
55
|
+
return nil
|
56
|
+
end
|
57
|
+
|
58
|
+
# Store the results in shared values
|
59
|
+
Actions.lane_context[SharedValues::GITHUB_DISMISS_PULL_REVIEW_STATUS_CODE] = status_code
|
60
|
+
Actions.lane_context[SharedValues::GITHUB_DISMISS_PULL_REVIEW_RESPONSE] = response[:body]
|
61
|
+
Actions.lane_context[SharedValues::GITHUB_DISMISS_PULL_REVIEW_JSON] = json_response
|
62
|
+
|
63
|
+
return result
|
64
|
+
end
|
65
|
+
|
66
|
+
#####################################################
|
67
|
+
# @!group Documentation
|
68
|
+
#####################################################
|
69
|
+
|
70
|
+
def description
|
71
|
+
"Dismiss a review for a pull request"
|
72
|
+
end
|
73
|
+
|
74
|
+
def details
|
75
|
+
[
|
76
|
+
"Dismisses a review for a pull request.",
|
77
|
+
"You must provide your GitHub Personal token (get one from https://github.com/settings/tokens/new).",
|
78
|
+
"API Documentation: https://docs.github.com/en/rest/pulls/reviews#dismiss-a-review-for-a-pull-request"
|
79
|
+
].join("\n")
|
80
|
+
end
|
81
|
+
|
82
|
+
def available_options
|
83
|
+
[
|
84
|
+
FastlaneCore::ConfigItem.new(key: :api_token,
|
85
|
+
env_name: "GITHUB_API_TOKEN",
|
86
|
+
description: "GitHub API token",
|
87
|
+
optional: false,
|
88
|
+
sensitive: true,
|
89
|
+
code_gen_sensitive: true,
|
90
|
+
default_value: ENV["GITHUB_API_TOKEN"],
|
91
|
+
verify_block: proc do |value|
|
92
|
+
UI.user_error!("No GitHub API token given, pass using `api_token: 'token'`") if value.to_s.empty?
|
93
|
+
end),
|
94
|
+
FastlaneCore::ConfigItem.new(key: :server_url,
|
95
|
+
env_name: "GITHUB_API_SERVER_URL",
|
96
|
+
description: "GitHub API server URL",
|
97
|
+
optional: true,
|
98
|
+
default_value: "https://api.github.com"),
|
99
|
+
FastlaneCore::ConfigItem.new(key: :repo_owner,
|
100
|
+
env_name: "GITHUB_API_REPO_OWNER",
|
101
|
+
description: "Owner of the repository",
|
102
|
+
optional: false),
|
103
|
+
FastlaneCore::ConfigItem.new(key: :repo_name,
|
104
|
+
env_name: "GITHUB_API_REPO_NAME",
|
105
|
+
description: "Name of the repository",
|
106
|
+
optional: false),
|
107
|
+
FastlaneCore::ConfigItem.new(key: :pull_number,
|
108
|
+
env_name: "GITHUB_API_PULL_NUMBER",
|
109
|
+
description: "The number of the pull request",
|
110
|
+
optional: false,
|
111
|
+
type: Integer),
|
112
|
+
FastlaneCore::ConfigItem.new(key: :review_id,
|
113
|
+
env_name: "GITHUB_API_REVIEW_ID",
|
114
|
+
description: "The ID of the review",
|
115
|
+
optional: false,
|
116
|
+
type: Integer),
|
117
|
+
FastlaneCore::ConfigItem.new(key: :message,
|
118
|
+
env_name: "GITHUB_API_REVIEW_DISMISS_MESSAGE",
|
119
|
+
description: "The message for the review dismissal",
|
120
|
+
optional: false,
|
121
|
+
type: String)
|
122
|
+
]
|
123
|
+
end
|
124
|
+
|
125
|
+
def output
|
126
|
+
[
|
127
|
+
['GITHUB_DISMISS_PULL_REVIEW_STATUS_CODE', 'The status code returned by the GitHub API'],
|
128
|
+
['GITHUB_DISMISS_PULL_REVIEW_RESPONSE', 'The full response body returned by the GitHub API'],
|
129
|
+
['GITHUB_DISMISS_PULL_REVIEW_JSON', 'The parsed JSON response returned by the GitHub API']
|
130
|
+
]
|
131
|
+
end
|
132
|
+
|
133
|
+
def return_value
|
134
|
+
"Returns a hash containing the status code, response body, and parsed JSON response from the GitHub API."
|
135
|
+
end
|
136
|
+
|
137
|
+
def authors
|
138
|
+
["crazymanish"]
|
139
|
+
end
|
140
|
+
|
141
|
+
def is_supported?(platform)
|
142
|
+
true
|
143
|
+
end
|
144
|
+
|
145
|
+
def example_code
|
146
|
+
[
|
147
|
+
'github_dismiss_pull_review(
|
148
|
+
repo_owner: "octocat",
|
149
|
+
repo_name: "Hello-World",
|
150
|
+
pull_number: 42,
|
151
|
+
review_id: 80,
|
152
|
+
message: "Dismissing this review as the code has been updated."
|
153
|
+
)',
|
154
|
+
'dismissed_review = github_dismiss_pull_review(
|
155
|
+
repo_owner: "octocat",
|
156
|
+
repo_name: "Hello-World",
|
157
|
+
pull_number: 42,
|
158
|
+
review_id: 80,
|
159
|
+
message: "This review is no longer relevant."
|
160
|
+
)
|
161
|
+
|
162
|
+
puts "Review dismissed successfully with status: #{dismissed_review[:status]}"'
|
163
|
+
]
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
@@ -0,0 +1,166 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/github_api_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
module SharedValues
|
7
|
+
GITHUB_GET_ISSUE_STATUS_CODE = :GITHUB_GET_ISSUE_STATUS_CODE
|
8
|
+
GITHUB_GET_ISSUE_RESPONSE = :GITHUB_GET_ISSUE_RESPONSE
|
9
|
+
GITHUB_GET_ISSUE_JSON = :GITHUB_GET_ISSUE_JSON
|
10
|
+
end
|
11
|
+
|
12
|
+
class GithubGetIssueAction < 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
|
+
issue_number = params[:issue_number]
|
23
|
+
|
24
|
+
# Validate parameters
|
25
|
+
UI.user_error!("No GitHub issue number given, pass using `issue_number: 123`") unless issue_number.to_s.length > 0
|
26
|
+
|
27
|
+
# Build the path
|
28
|
+
path = "/repos/#{repo_owner}/#{repo_name}/issues/#{issue_number}"
|
29
|
+
|
30
|
+
UI.message("Fetching issue ##{issue_number} from #{repo_owner}/#{repo_name}")
|
31
|
+
response = Helper::GithubApiHelper.github_api_request(
|
32
|
+
token: api_token,
|
33
|
+
path: path,
|
34
|
+
method: :get,
|
35
|
+
server_url: server_url
|
36
|
+
)
|
37
|
+
|
38
|
+
status_code = response[:status]
|
39
|
+
json_response = response[:json]
|
40
|
+
result = {
|
41
|
+
status: status_code,
|
42
|
+
body: response[:body],
|
43
|
+
json: json_response
|
44
|
+
}
|
45
|
+
|
46
|
+
if status_code.between?(200, 299)
|
47
|
+
UI.success("Successfully fetched issue ##{issue_number} from #{repo_owner}/#{repo_name}")
|
48
|
+
else
|
49
|
+
UI.error("Error fetching issue: #{status_code}")
|
50
|
+
UI.error(response[:body])
|
51
|
+
UI.user_error!("GitHub API returned #{status_code}: #{response[:body]}")
|
52
|
+
return nil
|
53
|
+
end
|
54
|
+
|
55
|
+
# Store the results in shared values
|
56
|
+
Actions.lane_context[SharedValues::GITHUB_GET_ISSUE_STATUS_CODE] = status_code
|
57
|
+
Actions.lane_context[SharedValues::GITHUB_GET_ISSUE_RESPONSE] = response[:body]
|
58
|
+
Actions.lane_context[SharedValues::GITHUB_GET_ISSUE_JSON] = json_response
|
59
|
+
|
60
|
+
return result
|
61
|
+
end
|
62
|
+
|
63
|
+
#####################################################
|
64
|
+
# @!group Documentation
|
65
|
+
#####################################################
|
66
|
+
|
67
|
+
def description
|
68
|
+
"Gets a specific GitHub issue by number"
|
69
|
+
end
|
70
|
+
|
71
|
+
def details
|
72
|
+
[
|
73
|
+
"Gets a specific issue from a GitHub repository by its issue number.",
|
74
|
+
"You must provide your GitHub Personal token (get one from https://github.com/settings/tokens/new).",
|
75
|
+
"API Documentation: https://docs.github.com/en/rest/issues/issues#get-an-issue"
|
76
|
+
].join("\n")
|
77
|
+
end
|
78
|
+
|
79
|
+
def available_options
|
80
|
+
[
|
81
|
+
FastlaneCore::ConfigItem.new(key: :api_token,
|
82
|
+
env_name: "GITHUB_API_TOKEN",
|
83
|
+
description: "GitHub API token",
|
84
|
+
optional: false,
|
85
|
+
sensitive: true,
|
86
|
+
code_gen_sensitive: true,
|
87
|
+
default_value: ENV["GITHUB_API_TOKEN"],
|
88
|
+
verify_block: proc do |value|
|
89
|
+
UI.user_error!("No GitHub API token given, pass using `api_token: 'token'`") if value.to_s.empty?
|
90
|
+
end),
|
91
|
+
FastlaneCore::ConfigItem.new(key: :server_url,
|
92
|
+
env_name: "GITHUB_API_SERVER_URL",
|
93
|
+
description: "GitHub API server URL",
|
94
|
+
optional: true,
|
95
|
+
default_value: "https://api.github.com"),
|
96
|
+
FastlaneCore::ConfigItem.new(key: :repo_owner,
|
97
|
+
env_name: "GITHUB_API_REPO_OWNER",
|
98
|
+
description: "Repository owner (organization or username)",
|
99
|
+
optional: false,
|
100
|
+
type: String,
|
101
|
+
verify_block: proc do |value|
|
102
|
+
UI.user_error!("No repository owner provided, pass using `repo_owner: 'owner'`") if value.to_s.empty?
|
103
|
+
end),
|
104
|
+
FastlaneCore::ConfigItem.new(key: :repo_name,
|
105
|
+
env_name: "GITHUB_API_REPO_NAME",
|
106
|
+
description: "Repository name",
|
107
|
+
optional: false,
|
108
|
+
type: String,
|
109
|
+
verify_block: proc do |value|
|
110
|
+
UI.user_error!("No repository name provided, pass using `repo_name: 'name'`") if value.to_s.empty?
|
111
|
+
end),
|
112
|
+
FastlaneCore::ConfigItem.new(key: :issue_number,
|
113
|
+
env_name: "GITHUB_API_ISSUE_NUMBER",
|
114
|
+
description: "The issue number",
|
115
|
+
optional: false,
|
116
|
+
type: Integer)
|
117
|
+
]
|
118
|
+
end
|
119
|
+
|
120
|
+
def output
|
121
|
+
[
|
122
|
+
['GITHUB_GET_ISSUE_STATUS_CODE', 'The status code returned from the GitHub API'],
|
123
|
+
['GITHUB_GET_ISSUE_RESPONSE', 'The full response body from the GitHub API'],
|
124
|
+
['GITHUB_GET_ISSUE_JSON', 'The parsed JSON returned from the GitHub API']
|
125
|
+
]
|
126
|
+
end
|
127
|
+
|
128
|
+
def return_value
|
129
|
+
"A hash including the HTTP status code (:status), the response body (:body), and the parsed JSON (:json)."
|
130
|
+
end
|
131
|
+
|
132
|
+
def authors
|
133
|
+
["crazymanish"]
|
134
|
+
end
|
135
|
+
|
136
|
+
def example_code
|
137
|
+
[
|
138
|
+
'github_get_issue(
|
139
|
+
api_token: ENV["GITHUB_API_TOKEN"],
|
140
|
+
repo_owner: "fastlane",
|
141
|
+
repo_name: "fastlane",
|
142
|
+
issue_number: 123
|
143
|
+
)',
|
144
|
+
'# You can also access the response data
|
145
|
+
result = github_get_issue(
|
146
|
+
api_token: ENV["GITHUB_API_TOKEN"],
|
147
|
+
repo_owner: "fastlane",
|
148
|
+
repo_name: "fastlane",
|
149
|
+
issue_number: 123
|
150
|
+
)
|
151
|
+
UI.message("Issue title: #{result[:json]["title"]}")
|
152
|
+
UI.message("Issue state: #{result[:json]["state"]}")'
|
153
|
+
]
|
154
|
+
end
|
155
|
+
|
156
|
+
def category
|
157
|
+
:source_control
|
158
|
+
end
|
159
|
+
|
160
|
+
def is_supported?(platform)
|
161
|
+
true
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
@@ -0,0 +1,174 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/github_api_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
module SharedValues
|
7
|
+
GITHUB_GET_ISSUE_COMMENT_RESPONSE = :GITHUB_GET_ISSUE_COMMENT_RESPONSE
|
8
|
+
GITHUB_GET_ISSUE_COMMENT_JSON = :GITHUB_GET_ISSUE_COMMENT_JSON
|
9
|
+
GITHUB_GET_ISSUE_COMMENT_STATUS_CODE = :GITHUB_GET_ISSUE_COMMENT_STATUS_CODE
|
10
|
+
end
|
11
|
+
|
12
|
+
class GithubGetIssueCommentAction < 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
|
+
comment_id = params[:comment_id]
|
19
|
+
server_url = params[:server_url]
|
20
|
+
|
21
|
+
# Validate parameters (additional validation beyond what's in ConfigItem)
|
22
|
+
UI.user_error!("No comment ID provided, pass using `comment_id: 12345678`") unless comment_id.to_s.length > 0
|
23
|
+
|
24
|
+
# Prepare request parameters
|
25
|
+
path = "/repos/#{repo_owner}/#{repo_name}/issues/comments/#{comment_id}"
|
26
|
+
|
27
|
+
# Make the request
|
28
|
+
UI.message("Fetching comment ID #{comment_id} from #{repo_owner}/#{repo_name}")
|
29
|
+
response = Helper::GithubApiHelper.github_api_request(
|
30
|
+
token: token,
|
31
|
+
path: path,
|
32
|
+
method: :get,
|
33
|
+
server_url: server_url
|
34
|
+
)
|
35
|
+
|
36
|
+
status_code = response.key?('status') ? response['status'] : nil
|
37
|
+
result = {
|
38
|
+
status: status_code,
|
39
|
+
body: response,
|
40
|
+
json: response
|
41
|
+
}
|
42
|
+
|
43
|
+
if response.key?('error')
|
44
|
+
UI.error("GitHub responded with an error: #{response['error']}")
|
45
|
+
UI.user_error!("GitHub API error: #{response['error']}")
|
46
|
+
return nil
|
47
|
+
end
|
48
|
+
|
49
|
+
if response['message'] && status_code && status_code >= 400
|
50
|
+
UI.error("GitHub API error: #{response['message']}")
|
51
|
+
UI.user_error!("GitHub API error: #{response['message']} (Status code: #{status_code})")
|
52
|
+
return nil
|
53
|
+
end
|
54
|
+
|
55
|
+
# Print comment user info
|
56
|
+
if response['user'] && response['user']['login']
|
57
|
+
user = response['user']['login']
|
58
|
+
UI.success("Successfully fetched comment ID #{comment_id} by #{user}")
|
59
|
+
else
|
60
|
+
UI.success("Successfully fetched comment ID #{comment_id}")
|
61
|
+
end
|
62
|
+
|
63
|
+
# Set the shared values
|
64
|
+
Actions.lane_context[SharedValues::GITHUB_GET_ISSUE_COMMENT_STATUS_CODE] = status_code
|
65
|
+
Actions.lane_context[SharedValues::GITHUB_GET_ISSUE_COMMENT_RESPONSE] = response
|
66
|
+
Actions.lane_context[SharedValues::GITHUB_GET_ISSUE_COMMENT_JSON] = response
|
67
|
+
|
68
|
+
return result
|
69
|
+
end
|
70
|
+
|
71
|
+
#####################################################
|
72
|
+
# @!group Documentation
|
73
|
+
#####################################################
|
74
|
+
|
75
|
+
def description
|
76
|
+
"Gets a specific comment from a GitHub issue"
|
77
|
+
end
|
78
|
+
|
79
|
+
def details
|
80
|
+
[
|
81
|
+
"This action fetches a specific comment from a GitHub issue by its comment ID.",
|
82
|
+
"It requires a valid GitHub API token with appropriate permissions.",
|
83
|
+
"Documentation: [https://docs.github.com/en/rest/issues/comments](https://docs.github.com/en/rest/issues/comments#get-an-issue-comment)"
|
84
|
+
].join("\n")
|
85
|
+
end
|
86
|
+
|
87
|
+
def available_options
|
88
|
+
[
|
89
|
+
FastlaneCore::ConfigItem.new(key: :api_token,
|
90
|
+
env_name: "GITHUB_API_TOKEN",
|
91
|
+
description: "GitHub API token with repo permissions",
|
92
|
+
optional: false,
|
93
|
+
type: String,
|
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: "Repository owner (organization or username)",
|
108
|
+
optional: false,
|
109
|
+
type: String,
|
110
|
+
verify_block: proc do |value|
|
111
|
+
UI.user_error!("No repository owner provided, pass using `repo_owner: 'owner'`") if value.to_s.empty?
|
112
|
+
end),
|
113
|
+
FastlaneCore::ConfigItem.new(key: :repo_name,
|
114
|
+
env_name: "GITHUB_API_REPO_NAME",
|
115
|
+
description: "Repository name",
|
116
|
+
optional: false,
|
117
|
+
type: String,
|
118
|
+
verify_block: proc do |value|
|
119
|
+
UI.user_error!("No repository name provided, pass using `repo_name: 'name'`") if value.to_s.empty?
|
120
|
+
end),
|
121
|
+
FastlaneCore::ConfigItem.new(key: :comment_id,
|
122
|
+
description: "The ID of the comment to fetch",
|
123
|
+
optional: false,
|
124
|
+
type: Integer)
|
125
|
+
]
|
126
|
+
end
|
127
|
+
|
128
|
+
def output
|
129
|
+
[
|
130
|
+
['GITHUB_GET_ISSUE_COMMENT_STATUS_CODE', 'The status code returned from the GitHub API'],
|
131
|
+
['GITHUB_GET_ISSUE_COMMENT_RESPONSE', 'The full response from the GitHub API'],
|
132
|
+
['GITHUB_GET_ISSUE_COMMENT_JSON', 'The JSON data returned from the GitHub API']
|
133
|
+
]
|
134
|
+
end
|
135
|
+
|
136
|
+
def return_value
|
137
|
+
"A hash including the HTTP status code (:status), the response body (:body), and the parsed JSON (:json)."
|
138
|
+
end
|
139
|
+
|
140
|
+
def authors
|
141
|
+
["crazymanish"]
|
142
|
+
end
|
143
|
+
|
144
|
+
def example_code
|
145
|
+
[
|
146
|
+
'github_get_issue_comment(
|
147
|
+
api_token: ENV["GITHUB_API_TOKEN"],
|
148
|
+
repo_owner: "fastlane",
|
149
|
+
repo_name: "fastlane",
|
150
|
+
comment_id: 12345678
|
151
|
+
)',
|
152
|
+
'# You can also access the response data
|
153
|
+
result = github_get_issue_comment(
|
154
|
+
api_token: ENV["GITHUB_API_TOKEN"],
|
155
|
+
repo_owner: "fastlane",
|
156
|
+
repo_name: "fastlane",
|
157
|
+
comment_id: 12345678
|
158
|
+
)
|
159
|
+
UI.message("Comment by: #{result[:json]["user"]["login"]}")
|
160
|
+
UI.message("Comment body: #{result[:json]["body"]}")'
|
161
|
+
]
|
162
|
+
end
|
163
|
+
|
164
|
+
def category
|
165
|
+
:source_control
|
166
|
+
end
|
167
|
+
|
168
|
+
def is_supported?(platform)
|
169
|
+
true
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
@@ -0,0 +1,169 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/github_api_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
module SharedValues
|
7
|
+
GITHUB_GET_ISSUE_EVENT_RESPONSE = :GITHUB_GET_ISSUE_EVENT_RESPONSE
|
8
|
+
GITHUB_GET_ISSUE_EVENT_JSON = :GITHUB_GET_ISSUE_EVENT_JSON
|
9
|
+
GITHUB_GET_ISSUE_EVENT_STATUS_CODE = :GITHUB_GET_ISSUE_EVENT_STATUS_CODE
|
10
|
+
end
|
11
|
+
|
12
|
+
class GithubGetIssueEventAction < 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
|
+
event_id = params[:event_id]
|
19
|
+
server_url = params[:server_url]
|
20
|
+
|
21
|
+
# Validate parameters (additional validation beyond what's in ConfigItem)
|
22
|
+
UI.user_error!("No event ID provided, pass using `event_id: 12345678`") unless event_id.to_s.length > 0
|
23
|
+
|
24
|
+
# Prepare request parameters
|
25
|
+
path = "/repos/#{repo_owner}/#{repo_name}/issues/events/#{event_id}"
|
26
|
+
|
27
|
+
# Make the request
|
28
|
+
UI.message("Fetching issue event ##{event_id} from #{repo_owner}/#{repo_name}")
|
29
|
+
response = Helper::GithubApiHelper.github_api_request(
|
30
|
+
token: token,
|
31
|
+
path: path,
|
32
|
+
method: :get,
|
33
|
+
server_url: server_url
|
34
|
+
)
|
35
|
+
|
36
|
+
status_code = response.key?('status') ? response['status'] : nil
|
37
|
+
result = {
|
38
|
+
status: status_code,
|
39
|
+
body: response,
|
40
|
+
json: response
|
41
|
+
}
|
42
|
+
|
43
|
+
if response.key?('error')
|
44
|
+
UI.error("GitHub responded with an error: #{response['error']}")
|
45
|
+
UI.user_error!("GitHub API error: #{response['error']}")
|
46
|
+
return nil
|
47
|
+
end
|
48
|
+
|
49
|
+
if response['message'] && status_code && status_code >= 400
|
50
|
+
UI.error("GitHub API error: #{response['message']}")
|
51
|
+
UI.user_error!("GitHub API error: #{response['message']} (Status code: #{status_code})")
|
52
|
+
return nil
|
53
|
+
end
|
54
|
+
|
55
|
+
# Print event details
|
56
|
+
event_type = response['event'] || 'unknown'
|
57
|
+
UI.success("Successfully fetched issue event ##{event_id} from #{repo_owner}/#{repo_name} (type: #{event_type})")
|
58
|
+
|
59
|
+
# Set the shared values
|
60
|
+
Actions.lane_context[SharedValues::GITHUB_GET_ISSUE_EVENT_STATUS_CODE] = status_code
|
61
|
+
Actions.lane_context[SharedValues::GITHUB_GET_ISSUE_EVENT_RESPONSE] = response
|
62
|
+
Actions.lane_context[SharedValues::GITHUB_GET_ISSUE_EVENT_JSON] = response
|
63
|
+
|
64
|
+
return result
|
65
|
+
end
|
66
|
+
|
67
|
+
#####################################################
|
68
|
+
# @!group Documentation
|
69
|
+
#####################################################
|
70
|
+
|
71
|
+
def description
|
72
|
+
"Gets a specific GitHub issue event by ID"
|
73
|
+
end
|
74
|
+
|
75
|
+
def details
|
76
|
+
[
|
77
|
+
"This action fetches a specific issue event from a GitHub repository by its event ID.",
|
78
|
+
"It requires a valid GitHub API token with appropriate permissions.",
|
79
|
+
"Documentation: [https://docs.github.com/en/rest/issues/events](https://docs.github.com/en/rest/issues/events#get-an-issue-event)"
|
80
|
+
].join("\n")
|
81
|
+
end
|
82
|
+
|
83
|
+
def available_options
|
84
|
+
[
|
85
|
+
FastlaneCore::ConfigItem.new(key: :api_token,
|
86
|
+
env_name: "GITHUB_API_TOKEN",
|
87
|
+
description: "GitHub API token with repo permissions",
|
88
|
+
optional: false,
|
89
|
+
sensitive: true,
|
90
|
+
code_gen_sensitive: true,
|
91
|
+
default_value: ENV["GITHUB_API_TOKEN"],
|
92
|
+
type: String,
|
93
|
+
verify_block: proc do |value|
|
94
|
+
UI.user_error!("No GitHub API token given, pass using `api_token: 'token'`") if value.to_s.empty?
|
95
|
+
end),
|
96
|
+
FastlaneCore::ConfigItem.new(key: :server_url,
|
97
|
+
env_name: "GITHUB_API_SERVER_URL",
|
98
|
+
description: "GitHub API server URL",
|
99
|
+
optional: true,
|
100
|
+
default_value: "https://api.github.com"),
|
101
|
+
FastlaneCore::ConfigItem.new(key: :repo_owner,
|
102
|
+
env_name: "GITHUB_API_REPO_OWNER",
|
103
|
+
description: "Repository owner (organization or username)",
|
104
|
+
optional: false,
|
105
|
+
type: String,
|
106
|
+
verify_block: proc do |value|
|
107
|
+
UI.user_error!("No repository owner provided, pass using `repo_owner: 'owner'`") if value.to_s.empty?
|
108
|
+
end),
|
109
|
+
FastlaneCore::ConfigItem.new(key: :repo_name,
|
110
|
+
env_name: "GITHUB_API_REPO_NAME",
|
111
|
+
description: "Repository name",
|
112
|
+
optional: false,
|
113
|
+
type: String,
|
114
|
+
verify_block: proc do |value|
|
115
|
+
UI.user_error!("No repository name provided, pass using `repo_name: 'name'`") if value.to_s.empty?
|
116
|
+
end),
|
117
|
+
FastlaneCore::ConfigItem.new(key: :event_id,
|
118
|
+
description: "The issue event ID",
|
119
|
+
optional: false,
|
120
|
+
type: Integer)
|
121
|
+
]
|
122
|
+
end
|
123
|
+
|
124
|
+
def output
|
125
|
+
[
|
126
|
+
['GITHUB_GET_ISSUE_EVENT_STATUS_CODE', 'The status code returned from the GitHub API'],
|
127
|
+
['GITHUB_GET_ISSUE_EVENT_RESPONSE', 'The full response from the GitHub API'],
|
128
|
+
['GITHUB_GET_ISSUE_EVENT_JSON', 'The JSON data returned from the GitHub API']
|
129
|
+
]
|
130
|
+
end
|
131
|
+
|
132
|
+
def return_value
|
133
|
+
"A hash including the HTTP status code (:status), the response body (:body), and the parsed JSON (:json)."
|
134
|
+
end
|
135
|
+
|
136
|
+
def authors
|
137
|
+
["crazymanish"]
|
138
|
+
end
|
139
|
+
|
140
|
+
def example_code
|
141
|
+
[
|
142
|
+
'github_get_issue_event(
|
143
|
+
api_token: ENV["GITHUB_API_TOKEN"],
|
144
|
+
repo_owner: "fastlane",
|
145
|
+
repo_name: "fastlane",
|
146
|
+
event_id: 12345678
|
147
|
+
)',
|
148
|
+
'# You can also access the response data
|
149
|
+
result = github_get_issue_event(
|
150
|
+
api_token: ENV["GITHUB_API_TOKEN"],
|
151
|
+
repo_owner: "fastlane",
|
152
|
+
repo_name: "fastlane",
|
153
|
+
event_id: 12345678
|
154
|
+
)
|
155
|
+
UI.message("Event type: #{result[:json]["event"]}, actor: #{result[:json]["actor"]["login"]}")'
|
156
|
+
]
|
157
|
+
end
|
158
|
+
|
159
|
+
def category
|
160
|
+
:source_control
|
161
|
+
end
|
162
|
+
|
163
|
+
def is_supported?(platform)
|
164
|
+
true
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|