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,224 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/github_api_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
module SharedValues
|
7
|
+
GITHUB_CREATE_PULL_REVIEW_STATUS_CODE = :GITHUB_CREATE_PULL_REVIEW_STATUS_CODE
|
8
|
+
GITHUB_CREATE_PULL_REVIEW_RESPONSE = :GITHUB_CREATE_PULL_REVIEW_RESPONSE
|
9
|
+
GITHUB_CREATE_PULL_REVIEW_JSON = :GITHUB_CREATE_PULL_REVIEW_JSON
|
10
|
+
end
|
11
|
+
|
12
|
+
class GithubCreatePullReviewAction < 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
|
+
|
24
|
+
# Build the path
|
25
|
+
path = "/repos/#{repo_owner}/#{repo_name}/pulls/#{pull_number}/reviews"
|
26
|
+
|
27
|
+
# Build body parameters
|
28
|
+
body_params = {}
|
29
|
+
body_params[:commit_id] = params[:commit_id] if params[:commit_id]
|
30
|
+
body_params[:body] = params[:body] if params[:body]
|
31
|
+
body_params[:event] = params[:event] if params[:event]
|
32
|
+
|
33
|
+
# Add comment review if comments parameter is provided
|
34
|
+
if params[:comments] && !params[:comments].empty?
|
35
|
+
body_params[:comments] = params[:comments]
|
36
|
+
end
|
37
|
+
|
38
|
+
UI.message("Creating review for pull request ##{pull_number} in #{repo_owner}/#{repo_name}")
|
39
|
+
response = Helper::GithubApiHelper.github_api_request(
|
40
|
+
token: api_token,
|
41
|
+
path: path,
|
42
|
+
params: body_params,
|
43
|
+
method: :post,
|
44
|
+
server_url: server_url
|
45
|
+
)
|
46
|
+
|
47
|
+
status_code = response[:status]
|
48
|
+
json_response = response[:json]
|
49
|
+
result = {
|
50
|
+
status: status_code,
|
51
|
+
body: response[:body],
|
52
|
+
json: json_response
|
53
|
+
}
|
54
|
+
|
55
|
+
if status_code.between?(200, 299)
|
56
|
+
review_id = json_response['id']
|
57
|
+
UI.success("Successfully created review #{review_id} for pull request ##{pull_number}")
|
58
|
+
else
|
59
|
+
UI.error("Error creating pull request review: #{status_code}")
|
60
|
+
UI.error(response[:body])
|
61
|
+
UI.user_error!("GitHub API returned #{status_code}: #{response[:body]}")
|
62
|
+
return nil
|
63
|
+
end
|
64
|
+
|
65
|
+
# Store the results in shared values
|
66
|
+
Actions.lane_context[SharedValues::GITHUB_CREATE_PULL_REVIEW_STATUS_CODE] = status_code
|
67
|
+
Actions.lane_context[SharedValues::GITHUB_CREATE_PULL_REVIEW_RESPONSE] = response[:body]
|
68
|
+
Actions.lane_context[SharedValues::GITHUB_CREATE_PULL_REVIEW_JSON] = json_response
|
69
|
+
|
70
|
+
return result
|
71
|
+
end
|
72
|
+
|
73
|
+
#####################################################
|
74
|
+
# @!group Documentation
|
75
|
+
#####################################################
|
76
|
+
|
77
|
+
def description
|
78
|
+
"Creates a review for a pull request"
|
79
|
+
end
|
80
|
+
|
81
|
+
def details
|
82
|
+
[
|
83
|
+
"Creates a new review for a specified pull request in a GitHub repository.",
|
84
|
+
"You must provide your GitHub Personal token (get one from https://github.com/settings/tokens/new).",
|
85
|
+
"API Documentation: https://docs.github.com/en/rest/pulls/reviews#create-a-review-for-a-pull-request"
|
86
|
+
].join("\n")
|
87
|
+
end
|
88
|
+
|
89
|
+
def available_options
|
90
|
+
[
|
91
|
+
FastlaneCore::ConfigItem.new(key: :api_token,
|
92
|
+
env_name: "GITHUB_API_TOKEN",
|
93
|
+
description: "GitHub API token",
|
94
|
+
optional: false,
|
95
|
+
sensitive: true,
|
96
|
+
code_gen_sensitive: true,
|
97
|
+
default_value: ENV["GITHUB_API_TOKEN"],
|
98
|
+
verify_block: proc do |value|
|
99
|
+
UI.user_error!("No GitHub API token given, pass using `api_token: 'token'`") if value.to_s.empty?
|
100
|
+
end),
|
101
|
+
FastlaneCore::ConfigItem.new(key: :server_url,
|
102
|
+
env_name: "GITHUB_API_SERVER_URL",
|
103
|
+
description: "GitHub API server URL",
|
104
|
+
optional: true,
|
105
|
+
default_value: "https://api.github.com"),
|
106
|
+
FastlaneCore::ConfigItem.new(key: :repo_owner,
|
107
|
+
env_name: "GITHUB_API_REPO_OWNER",
|
108
|
+
description: "Owner of the repository",
|
109
|
+
optional: false),
|
110
|
+
FastlaneCore::ConfigItem.new(key: :repo_name,
|
111
|
+
env_name: "GITHUB_API_REPO_NAME",
|
112
|
+
description: "Name of the repository",
|
113
|
+
optional: false),
|
114
|
+
FastlaneCore::ConfigItem.new(key: :pull_number,
|
115
|
+
env_name: "GITHUB_API_PULL_NUMBER",
|
116
|
+
description: "The number of the pull request",
|
117
|
+
optional: false,
|
118
|
+
type: Integer),
|
119
|
+
FastlaneCore::ConfigItem.new(key: :commit_id,
|
120
|
+
env_name: "GITHUB_API_COMMIT_ID",
|
121
|
+
description: "The SHA of the commit that needs a review. Required when using REQUEST_CHANGES or COMMENT for events",
|
122
|
+
optional: true,
|
123
|
+
type: String),
|
124
|
+
FastlaneCore::ConfigItem.new(key: :body,
|
125
|
+
env_name: "GITHUB_API_REVIEW_BODY",
|
126
|
+
description: "Text content of the review",
|
127
|
+
optional: true,
|
128
|
+
type: String),
|
129
|
+
FastlaneCore::ConfigItem.new(key: :event,
|
130
|
+
env_name: "GITHUB_API_REVIEW_EVENT",
|
131
|
+
description: "The review action to perform: APPROVE, REQUEST_CHANGES, or COMMENT",
|
132
|
+
optional: true,
|
133
|
+
type: String,
|
134
|
+
verify_block: proc do |value|
|
135
|
+
UI.user_error!("Event must be one of: APPROVE, REQUEST_CHANGES, COMMENT") unless ["APPROVE", "REQUEST_CHANGES", "COMMENT"].include?(value)
|
136
|
+
end),
|
137
|
+
FastlaneCore::ConfigItem.new(key: :comments,
|
138
|
+
env_name: "GITHUB_API_REVIEW_COMMENTS",
|
139
|
+
description: "An array of comments to make during the review (for line-by-line commenting)",
|
140
|
+
optional: true,
|
141
|
+
type: Array)
|
142
|
+
]
|
143
|
+
end
|
144
|
+
|
145
|
+
def output
|
146
|
+
[
|
147
|
+
['GITHUB_CREATE_PULL_REVIEW_STATUS_CODE', 'The status code returned by the GitHub API'],
|
148
|
+
['GITHUB_CREATE_PULL_REVIEW_RESPONSE', 'The full response body returned by the GitHub API'],
|
149
|
+
['GITHUB_CREATE_PULL_REVIEW_JSON', 'The parsed JSON response returned by the GitHub API']
|
150
|
+
]
|
151
|
+
end
|
152
|
+
|
153
|
+
def return_value
|
154
|
+
"Returns a hash containing the status code, response body, and parsed JSON response from the GitHub API."
|
155
|
+
end
|
156
|
+
|
157
|
+
def authors
|
158
|
+
["crazymanish"]
|
159
|
+
end
|
160
|
+
|
161
|
+
def example_code
|
162
|
+
[
|
163
|
+
'github_create_pull_review(
|
164
|
+
api_token: ENV["GITHUB_API_TOKEN"],
|
165
|
+
repo_owner: "fastlane",
|
166
|
+
repo_name: "fastlane",
|
167
|
+
pull_number: 123,
|
168
|
+
event: "APPROVE",
|
169
|
+
body: "LGTM! Great work."
|
170
|
+
)',
|
171
|
+
'# Create a review with comments on specific lines
|
172
|
+
github_create_pull_review(
|
173
|
+
api_token: ENV["GITHUB_API_TOKEN"],
|
174
|
+
repo_owner: "fastlane",
|
175
|
+
repo_name: "fastlane",
|
176
|
+
pull_number: 123,
|
177
|
+
event: "COMMENT",
|
178
|
+
body: "Here are some comments on the pull request",
|
179
|
+
comments: [
|
180
|
+
{
|
181
|
+
path: "file.rb",
|
182
|
+
position: 10,
|
183
|
+
body: "Consider using a more descriptive variable name here"
|
184
|
+
},
|
185
|
+
{
|
186
|
+
path: "another_file.rb",
|
187
|
+
position: 5,
|
188
|
+
body: "This could be optimized"
|
189
|
+
}
|
190
|
+
]
|
191
|
+
)',
|
192
|
+
'# Request changes in a review
|
193
|
+
github_create_pull_review(
|
194
|
+
api_token: ENV["GITHUB_API_TOKEN"],
|
195
|
+
repo_owner: "fastlane",
|
196
|
+
repo_name: "fastlane",
|
197
|
+
pull_number: 123,
|
198
|
+
event: "REQUEST_CHANGES",
|
199
|
+
body: "Please make the following changes before this can be approved.",
|
200
|
+
commit_id: "abc123def456"
|
201
|
+
)',
|
202
|
+
'# Access the response data
|
203
|
+
result = github_create_pull_review(
|
204
|
+
api_token: ENV["GITHUB_API_TOKEN"],
|
205
|
+
repo_owner: "fastlane",
|
206
|
+
repo_name: "fastlane",
|
207
|
+
pull_number: 123,
|
208
|
+
event: "COMMENT"
|
209
|
+
)
|
210
|
+
UI.message("Created review ID: #{result[:json]["id"]}")'
|
211
|
+
]
|
212
|
+
end
|
213
|
+
|
214
|
+
def category
|
215
|
+
:source_control
|
216
|
+
end
|
217
|
+
|
218
|
+
def is_supported?(platform)
|
219
|
+
true
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
@@ -0,0 +1,230 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/github_api_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
module SharedValues
|
7
|
+
GITHUB_CREATE_REPOSITORY_STATUS_CODE = :GITHUB_CREATE_REPOSITORY_STATUS_CODE
|
8
|
+
GITHUB_CREATE_REPOSITORY_RESPONSE = :GITHUB_CREATE_REPOSITORY_RESPONSE
|
9
|
+
GITHUB_CREATE_REPOSITORY_JSON = :GITHUB_CREATE_REPOSITORY_JSON
|
10
|
+
end
|
11
|
+
|
12
|
+
class GithubCreateRepositoryAction < 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
|
+
name = params[:name]
|
21
|
+
|
22
|
+
# Validate parameters
|
23
|
+
UI.user_error!("No repository name given, pass using `name: 'repo-name'`") if name.to_s.empty?
|
24
|
+
|
25
|
+
# Build the path
|
26
|
+
path = "/user/repos"
|
27
|
+
|
28
|
+
# Build body parameters
|
29
|
+
body_params = {
|
30
|
+
name: name
|
31
|
+
}
|
32
|
+
|
33
|
+
# Add optional parameters if provided
|
34
|
+
body_params[:description] = params[:description] if params[:description]
|
35
|
+
body_params[:homepage] = params[:homepage] if params[:homepage]
|
36
|
+
body_params[:private] = params[:private] unless params[:private].nil?
|
37
|
+
body_params[:has_issues] = params[:has_issues] unless params[:has_issues].nil?
|
38
|
+
body_params[:has_projects] = params[:has_projects] unless params[:has_projects].nil?
|
39
|
+
body_params[:has_wiki] = params[:has_wiki] unless params[:has_wiki].nil?
|
40
|
+
body_params[:auto_init] = params[:auto_init] unless params[:auto_init].nil?
|
41
|
+
body_params[:license_template] = params[:license_template] if params[:license_template]
|
42
|
+
body_params[:allow_squash_merge] = params[:allow_squash_merge] unless params[:allow_squash_merge].nil?
|
43
|
+
body_params[:allow_merge_commit] = params[:allow_merge_commit] unless params[:allow_merge_commit].nil?
|
44
|
+
body_params[:allow_rebase_merge] = params[:allow_rebase_merge] unless params[:allow_rebase_merge].nil?
|
45
|
+
|
46
|
+
# If organization is provided, use the org repos endpoint
|
47
|
+
if params[:organization]
|
48
|
+
path = "/orgs/#{params[:organization]}/repos"
|
49
|
+
end
|
50
|
+
|
51
|
+
UI.message("Creating repository: #{name}")
|
52
|
+
response = Helper::GithubApiHelper.github_api_request(
|
53
|
+
token: api_token,
|
54
|
+
path: path,
|
55
|
+
params: body_params,
|
56
|
+
method: :post,
|
57
|
+
server_url: server_url
|
58
|
+
)
|
59
|
+
|
60
|
+
status_code = response[:status]
|
61
|
+
json_response = response[:json]
|
62
|
+
result = {
|
63
|
+
status: status_code,
|
64
|
+
body: response[:body],
|
65
|
+
json: json_response
|
66
|
+
}
|
67
|
+
|
68
|
+
if status_code.between?(200, 299)
|
69
|
+
UI.success("Successfully created repository: #{json_response['full_name']}")
|
70
|
+
else
|
71
|
+
UI.error("Error creating repository: #{status_code}")
|
72
|
+
UI.error(response[:body])
|
73
|
+
UI.user_error!("GitHub API returned #{status_code}: #{response[:body]}")
|
74
|
+
return nil
|
75
|
+
end
|
76
|
+
|
77
|
+
# Store the results in shared values
|
78
|
+
Actions.lane_context[SharedValues::GITHUB_CREATE_REPOSITORY_STATUS_CODE] = status_code
|
79
|
+
Actions.lane_context[SharedValues::GITHUB_CREATE_REPOSITORY_RESPONSE] = response[:body]
|
80
|
+
Actions.lane_context[SharedValues::GITHUB_CREATE_REPOSITORY_JSON] = json_response
|
81
|
+
|
82
|
+
return result
|
83
|
+
end
|
84
|
+
|
85
|
+
#####################################################
|
86
|
+
# @!group Documentation
|
87
|
+
#####################################################
|
88
|
+
|
89
|
+
def description
|
90
|
+
"Creates a new GitHub repository"
|
91
|
+
end
|
92
|
+
|
93
|
+
def details
|
94
|
+
[
|
95
|
+
"Creates a new repository on GitHub for the authenticated user or specified organization.",
|
96
|
+
"You must provide your GitHub Personal token (get one from https://github.com/settings/tokens/new).",
|
97
|
+
"API Documentation: https://docs.github.com/en/rest/repos/repos#create-a-repository-for-the-authenticated-user"
|
98
|
+
].join("\n")
|
99
|
+
end
|
100
|
+
|
101
|
+
def available_options
|
102
|
+
[
|
103
|
+
FastlaneCore::ConfigItem.new(key: :api_token,
|
104
|
+
env_name: "GITHUB_API_TOKEN",
|
105
|
+
description: "GitHub API token",
|
106
|
+
optional: false,
|
107
|
+
sensitive: true,
|
108
|
+
code_gen_sensitive: true,
|
109
|
+
default_value: ENV["GITHUB_API_TOKEN"],
|
110
|
+
verify_block: proc do |value|
|
111
|
+
UI.user_error!("No GitHub API token given, pass using `api_token: 'token'`") if value.to_s.empty?
|
112
|
+
end),
|
113
|
+
FastlaneCore::ConfigItem.new(key: :server_url,
|
114
|
+
env_name: "GITHUB_API_SERVER_URL",
|
115
|
+
description: "GitHub API server URL",
|
116
|
+
optional: true,
|
117
|
+
default_value: "https://api.github.com"),
|
118
|
+
FastlaneCore::ConfigItem.new(key: :name,
|
119
|
+
description: "The name of the new repository",
|
120
|
+
optional: false,
|
121
|
+
type: String,
|
122
|
+
verify_block: proc do |value|
|
123
|
+
UI.user_error!("No repository name provided, pass using `name: 'repo-name'`") if value.to_s.empty?
|
124
|
+
end),
|
125
|
+
FastlaneCore::ConfigItem.new(key: :organization,
|
126
|
+
description: "The organization name (if creating a repository for an organization)",
|
127
|
+
optional: true,
|
128
|
+
type: String),
|
129
|
+
FastlaneCore::ConfigItem.new(key: :description,
|
130
|
+
description: "A short description of the repository",
|
131
|
+
optional: true,
|
132
|
+
type: String),
|
133
|
+
FastlaneCore::ConfigItem.new(key: :homepage,
|
134
|
+
description: "A URL with more information about the repository",
|
135
|
+
optional: true,
|
136
|
+
type: String),
|
137
|
+
FastlaneCore::ConfigItem.new(key: :private,
|
138
|
+
description: "Whether the repository is private (true) or public (false)",
|
139
|
+
optional: true,
|
140
|
+
is_string: false),
|
141
|
+
FastlaneCore::ConfigItem.new(key: :has_issues,
|
142
|
+
description: "Whether to enable issues for this repository",
|
143
|
+
optional: true,
|
144
|
+
is_string: false),
|
145
|
+
FastlaneCore::ConfigItem.new(key: :has_projects,
|
146
|
+
description: "Whether to enable projects for this repository",
|
147
|
+
optional: true,
|
148
|
+
is_string: false),
|
149
|
+
FastlaneCore::ConfigItem.new(key: :has_wiki,
|
150
|
+
description: "Whether to enable the wiki for this repository",
|
151
|
+
optional: true,
|
152
|
+
is_string: false),
|
153
|
+
FastlaneCore::ConfigItem.new(key: :auto_init,
|
154
|
+
description: "Whether to create an initial commit with README",
|
155
|
+
optional: true,
|
156
|
+
is_string: false),
|
157
|
+
FastlaneCore::ConfigItem.new(key: :license_template,
|
158
|
+
description: "License template to include (e.g., 'mit', 'apache-2.0')",
|
159
|
+
optional: true,
|
160
|
+
type: String),
|
161
|
+
FastlaneCore::ConfigItem.new(key: :allow_squash_merge,
|
162
|
+
description: "Whether to allow squash merges for pull requests",
|
163
|
+
optional: true,
|
164
|
+
is_string: false),
|
165
|
+
FastlaneCore::ConfigItem.new(key: :allow_merge_commit,
|
166
|
+
description: "Whether to allow merge commits for pull requests",
|
167
|
+
optional: true,
|
168
|
+
is_string: false),
|
169
|
+
FastlaneCore::ConfigItem.new(key: :allow_rebase_merge,
|
170
|
+
description: "Whether to allow rebase merges for pull requests",
|
171
|
+
optional: true,
|
172
|
+
is_string: false)
|
173
|
+
]
|
174
|
+
end
|
175
|
+
|
176
|
+
def output
|
177
|
+
[
|
178
|
+
['GITHUB_CREATE_REPOSITORY_STATUS_CODE', 'The status code returned from the GitHub API'],
|
179
|
+
['GITHUB_CREATE_REPOSITORY_RESPONSE', 'The full response body from the GitHub API'],
|
180
|
+
['GITHUB_CREATE_REPOSITORY_JSON', 'The parsed JSON returned from the GitHub API']
|
181
|
+
]
|
182
|
+
end
|
183
|
+
|
184
|
+
def return_value
|
185
|
+
"A hash including the HTTP status code (:status), the response body (:body), and the parsed JSON (:json)."
|
186
|
+
end
|
187
|
+
|
188
|
+
def authors
|
189
|
+
["crazymanish"]
|
190
|
+
end
|
191
|
+
|
192
|
+
def example_code
|
193
|
+
[
|
194
|
+
'github_create_repository(
|
195
|
+
api_token: ENV["GITHUB_API_TOKEN"],
|
196
|
+
name: "my-new-repo",
|
197
|
+
description: "My awesome new repo",
|
198
|
+
private: true,
|
199
|
+
auto_init: true,
|
200
|
+
license_template: "mit"
|
201
|
+
)',
|
202
|
+
'# Create repository in an organization',
|
203
|
+
'github_create_repository(
|
204
|
+
api_token: ENV["GITHUB_API_TOKEN"],
|
205
|
+
name: "org-repo",
|
206
|
+
organization: "my-org",
|
207
|
+
private: false,
|
208
|
+
has_issues: true,
|
209
|
+
has_wiki: false
|
210
|
+
)',
|
211
|
+
'# You can also access the response data',
|
212
|
+
'result = github_create_repository(
|
213
|
+
api_token: ENV["GITHUB_API_TOKEN"],
|
214
|
+
name: "my-new-repo"
|
215
|
+
)
|
216
|
+
UI.message("Created repository URL: #{result[:json]["html_url"]}")'
|
217
|
+
]
|
218
|
+
end
|
219
|
+
|
220
|
+
def category
|
221
|
+
:source_control
|
222
|
+
end
|
223
|
+
|
224
|
+
def is_supported?(platform)
|
225
|
+
true
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|
@@ -0,0 +1,152 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/github_api_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
module SharedValues
|
7
|
+
GITHUB_DELETE_COMMIT_COMMENT_REACTION_STATUS_CODE = :GITHUB_DELETE_COMMIT_COMMENT_REACTION_STATUS_CODE
|
8
|
+
GITHUB_DELETE_COMMIT_COMMENT_REACTION_RESPONSE = :GITHUB_DELETE_COMMIT_COMMENT_REACTION_RESPONSE
|
9
|
+
end
|
10
|
+
|
11
|
+
class GithubDeleteCommitCommentReactionAction < Action
|
12
|
+
class << self
|
13
|
+
def run(params)
|
14
|
+
# Prepare API call parameters
|
15
|
+
server_url = params[:server_url]
|
16
|
+
api_token = params[:api_token]
|
17
|
+
repo_owner = params[:repo_owner]
|
18
|
+
repo_name = params[:repo_name]
|
19
|
+
comment_id = params[:comment_id]
|
20
|
+
reaction_id = params[:reaction_id]
|
21
|
+
|
22
|
+
# Build the path
|
23
|
+
path = "/repos/#{repo_owner}/#{repo_name}/comments/#{comment_id}/reactions/#{reaction_id}"
|
24
|
+
|
25
|
+
UI.message("Deleting reaction ##{reaction_id} for commit comment ##{comment_id} in #{repo_owner}/#{repo_name}")
|
26
|
+
response = Helper::GithubApiHelper.github_api_request(
|
27
|
+
token: api_token,
|
28
|
+
path: path,
|
29
|
+
method: :delete,
|
30
|
+
server_url: server_url,
|
31
|
+
headers: { 'Accept' => 'application/vnd.github.squirrel-girl-preview+json' }
|
32
|
+
)
|
33
|
+
|
34
|
+
status_code = response[:status]
|
35
|
+
result = {
|
36
|
+
status: status_code,
|
37
|
+
body: response[:body]
|
38
|
+
}
|
39
|
+
|
40
|
+
if status_code == 204
|
41
|
+
UI.success("Successfully deleted reaction ##{reaction_id} for commit comment ##{comment_id}")
|
42
|
+
else
|
43
|
+
UI.error("Error deleting reaction: #{status_code}")
|
44
|
+
UI.error(response[:body])
|
45
|
+
UI.user_error!("GitHub API returned #{status_code}: #{response[:body]}")
|
46
|
+
return nil
|
47
|
+
end
|
48
|
+
|
49
|
+
# Store the results in shared values
|
50
|
+
Actions.lane_context[SharedValues::GITHUB_DELETE_COMMIT_COMMENT_REACTION_STATUS_CODE] = status_code
|
51
|
+
Actions.lane_context[SharedValues::GITHUB_DELETE_COMMIT_COMMENT_REACTION_RESPONSE] = response[:body]
|
52
|
+
|
53
|
+
return result
|
54
|
+
end
|
55
|
+
|
56
|
+
#####################################################
|
57
|
+
# @!group Documentation
|
58
|
+
#####################################################
|
59
|
+
|
60
|
+
def description
|
61
|
+
"Delete a reaction from a commit comment"
|
62
|
+
end
|
63
|
+
|
64
|
+
def details
|
65
|
+
[
|
66
|
+
"Deletes a reaction from a commit comment.",
|
67
|
+
"You must provide your GitHub Personal token (get one from https://github.com/settings/tokens/new).",
|
68
|
+
"API Documentation: https://docs.github.com/en/rest/reactions/reactions#delete-a-commit-comment-reaction"
|
69
|
+
].join("\n")
|
70
|
+
end
|
71
|
+
|
72
|
+
def available_options
|
73
|
+
[
|
74
|
+
FastlaneCore::ConfigItem.new(key: :api_token,
|
75
|
+
env_name: "GITHUB_API_TOKEN",
|
76
|
+
description: "GitHub API token",
|
77
|
+
optional: false,
|
78
|
+
sensitive: true,
|
79
|
+
code_gen_sensitive: true,
|
80
|
+
default_value: ENV["GITHUB_API_TOKEN"],
|
81
|
+
verify_block: proc do |value|
|
82
|
+
UI.user_error!("No GitHub API token given, pass using `api_token: 'token'`") if value.to_s.empty?
|
83
|
+
end),
|
84
|
+
FastlaneCore::ConfigItem.new(key: :server_url,
|
85
|
+
env_name: "GITHUB_API_SERVER_URL",
|
86
|
+
description: "GitHub server url",
|
87
|
+
optional: true,
|
88
|
+
default_value: "https://api.github.com"),
|
89
|
+
FastlaneCore::ConfigItem.new(key: :repo_owner,
|
90
|
+
env_name: "GITHUB_API_REPO_OWNER",
|
91
|
+
description: "Owner of the repository",
|
92
|
+
optional: false),
|
93
|
+
FastlaneCore::ConfigItem.new(key: :repo_name,
|
94
|
+
env_name: "GITHUB_API_REPO_NAME",
|
95
|
+
description: "Name of the repository",
|
96
|
+
optional: false),
|
97
|
+
FastlaneCore::ConfigItem.new(key: :comment_id,
|
98
|
+
env_name: "GITHUB_API_COMMENT_ID",
|
99
|
+
description: "The ID of the commit comment",
|
100
|
+
optional: false,
|
101
|
+
type: Integer),
|
102
|
+
FastlaneCore::ConfigItem.new(key: :reaction_id,
|
103
|
+
env_name: "GITHUB_API_REACTION_ID",
|
104
|
+
description: "The ID of the reaction to delete",
|
105
|
+
optional: false,
|
106
|
+
type: Integer)
|
107
|
+
]
|
108
|
+
end
|
109
|
+
|
110
|
+
def output
|
111
|
+
[
|
112
|
+
['GITHUB_DELETE_COMMIT_COMMENT_REACTION_STATUS_CODE', 'The status code returned by the GitHub API'],
|
113
|
+
['GITHUB_DELETE_COMMIT_COMMENT_REACTION_RESPONSE', 'The full response body returned by the GitHub API']
|
114
|
+
]
|
115
|
+
end
|
116
|
+
|
117
|
+
def return_value
|
118
|
+
"Returns a hash containing the status code and response body from the GitHub API."
|
119
|
+
end
|
120
|
+
|
121
|
+
def authors
|
122
|
+
["crazymanish"]
|
123
|
+
end
|
124
|
+
|
125
|
+
def is_supported?(platform)
|
126
|
+
true
|
127
|
+
end
|
128
|
+
|
129
|
+
def example_code
|
130
|
+
[
|
131
|
+
'github_delete_commit_comment_reaction(
|
132
|
+
repo_owner: "octocat",
|
133
|
+
repo_name: "Hello-World",
|
134
|
+
comment_id: 123,
|
135
|
+
reaction_id: 456
|
136
|
+
)',
|
137
|
+
'result = github_delete_commit_comment_reaction(
|
138
|
+
repo_owner: "octocat",
|
139
|
+
repo_name: "Hello-World",
|
140
|
+
comment_id: 123,
|
141
|
+
reaction_id: 456
|
142
|
+
)
|
143
|
+
|
144
|
+
if result[:status] == 204
|
145
|
+
puts "Reaction deleted successfully!"
|
146
|
+
end'
|
147
|
+
]
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|