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,180 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/github_api_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
module SharedValues
|
7
|
+
GITHUB_LOCK_ISSUE_STATUS_CODE = :GITHUB_LOCK_ISSUE_STATUS_CODE
|
8
|
+
GITHUB_LOCK_ISSUE_RESPONSE = :GITHUB_LOCK_ISSUE_RESPONSE
|
9
|
+
GITHUB_LOCK_ISSUE_JSON = :GITHUB_LOCK_ISSUE_JSON
|
10
|
+
end
|
11
|
+
|
12
|
+
class GithubLockIssueAction < 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
|
+
lock_reason = params[:lock_reason]
|
24
|
+
|
25
|
+
# Validate parameters
|
26
|
+
UI.user_error!("No GitHub issue number given, pass using `issue_number: 123`") unless issue_number.to_s.length > 0
|
27
|
+
|
28
|
+
# Build the path
|
29
|
+
path = "/repos/#{repo_owner}/#{repo_name}/issues/#{issue_number}/lock"
|
30
|
+
|
31
|
+
# Build body parameters
|
32
|
+
body_params = {}
|
33
|
+
body_params[:lock_reason] = lock_reason if lock_reason
|
34
|
+
|
35
|
+
UI.message("Locking issue ##{issue_number} in #{repo_owner}/#{repo_name}")
|
36
|
+
response = Helper::GithubApiHelper.github_api_request(
|
37
|
+
token: api_token,
|
38
|
+
path: path,
|
39
|
+
params: body_params,
|
40
|
+
method: :put,
|
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) || status_code == 204
|
53
|
+
reason_text = lock_reason ? " with reason '#{lock_reason}'" : ""
|
54
|
+
UI.success("Successfully locked issue ##{issue_number}#{reason_text}")
|
55
|
+
else
|
56
|
+
UI.error("Error locking issue: #{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_LOCK_ISSUE_STATUS_CODE] = status_code
|
64
|
+
Actions.lane_context[SharedValues::GITHUB_LOCK_ISSUE_RESPONSE] = response[:body]
|
65
|
+
Actions.lane_context[SharedValues::GITHUB_LOCK_ISSUE_JSON] = json_response
|
66
|
+
|
67
|
+
return result
|
68
|
+
end
|
69
|
+
|
70
|
+
#####################################################
|
71
|
+
# @!group Documentation
|
72
|
+
#####################################################
|
73
|
+
|
74
|
+
def description
|
75
|
+
"Locks a GitHub issue"
|
76
|
+
end
|
77
|
+
|
78
|
+
def details
|
79
|
+
[
|
80
|
+
"Locks an issue in a GitHub repository, preventing further comments.",
|
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/issues/issues#lock-an-issue"
|
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: "Repository owner (organization or username)",
|
106
|
+
optional: false,
|
107
|
+
type: String,
|
108
|
+
verify_block: proc do |value|
|
109
|
+
UI.user_error!("No repository owner provided, pass using `repo_owner: 'owner'`") if value.to_s.empty?
|
110
|
+
end),
|
111
|
+
FastlaneCore::ConfigItem.new(key: :repo_name,
|
112
|
+
env_name: "GITHUB_API_REPO_NAME",
|
113
|
+
description: "Repository name",
|
114
|
+
optional: false,
|
115
|
+
type: String,
|
116
|
+
verify_block: proc do |value|
|
117
|
+
UI.user_error!("No repository name provided, pass using `repo_name: 'name'`") if value.to_s.empty?
|
118
|
+
end),
|
119
|
+
FastlaneCore::ConfigItem.new(key: :issue_number,
|
120
|
+
env_name: "GITHUB_API_ISSUE_NUMBER",
|
121
|
+
description: "The issue number to lock",
|
122
|
+
optional: false,
|
123
|
+
type: Integer),
|
124
|
+
FastlaneCore::ConfigItem.new(key: :lock_reason,
|
125
|
+
description: "The reason for locking the issue (off-topic, too heated, resolved, spam)",
|
126
|
+
optional: true,
|
127
|
+
type: String,
|
128
|
+
verify_block: proc do |value|
|
129
|
+
allowed_reasons = ['off-topic', 'too heated', 'resolved', 'spam']
|
130
|
+
UI.user_error!("Lock reason must be one of: #{allowed_reasons.join(', ')}") unless allowed_reasons.include?(value) || value.nil?
|
131
|
+
end)
|
132
|
+
]
|
133
|
+
end
|
134
|
+
|
135
|
+
def output
|
136
|
+
[
|
137
|
+
['GITHUB_LOCK_ISSUE_STATUS_CODE', 'The status code returned from the GitHub API'],
|
138
|
+
['GITHUB_LOCK_ISSUE_RESPONSE', 'The full response body from the GitHub API'],
|
139
|
+
['GITHUB_LOCK_ISSUE_JSON', 'The parsed JSON returned from the GitHub API']
|
140
|
+
]
|
141
|
+
end
|
142
|
+
|
143
|
+
def return_value
|
144
|
+
"A hash including the HTTP status code (:status), the response body (:body), and the parsed JSON (:json)."
|
145
|
+
end
|
146
|
+
|
147
|
+
def authors
|
148
|
+
["crazymanish"]
|
149
|
+
end
|
150
|
+
|
151
|
+
def example_code
|
152
|
+
[
|
153
|
+
'github_lock_issue(
|
154
|
+
api_token: ENV["GITHUB_API_TOKEN"],
|
155
|
+
repo_owner: "fastlane",
|
156
|
+
repo_name: "fastlane",
|
157
|
+
issue_number: 123
|
158
|
+
)',
|
159
|
+
'# Lock with a reason
|
160
|
+
github_lock_issue(
|
161
|
+
api_token: ENV["GITHUB_API_TOKEN"],
|
162
|
+
repo_owner: "fastlane",
|
163
|
+
repo_name: "fastlane",
|
164
|
+
issue_number: 123,
|
165
|
+
lock_reason: "resolved"
|
166
|
+
)'
|
167
|
+
]
|
168
|
+
end
|
169
|
+
|
170
|
+
def category
|
171
|
+
:source_control
|
172
|
+
end
|
173
|
+
|
174
|
+
def is_supported?(platform)
|
175
|
+
true
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
@@ -0,0 +1,191 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/github_api_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
module SharedValues
|
7
|
+
GITHUB_MERGE_PULL_STATUS_CODE = :GITHUB_MERGE_PULL_STATUS_CODE
|
8
|
+
GITHUB_MERGE_PULL_RESPONSE = :GITHUB_MERGE_PULL_RESPONSE
|
9
|
+
GITHUB_MERGE_PULL_JSON = :GITHUB_MERGE_PULL_JSON
|
10
|
+
end
|
11
|
+
|
12
|
+
class GithubMergePullAction < 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
|
+
commit_title = params[:commit_title]
|
24
|
+
commit_message = params[:commit_message]
|
25
|
+
merge_method = params[:merge_method]
|
26
|
+
sha = params[:sha]
|
27
|
+
|
28
|
+
# Build the body for the request
|
29
|
+
body = {}
|
30
|
+
body[:commit_title] = commit_title if commit_title
|
31
|
+
body[:commit_message] = commit_message if commit_message
|
32
|
+
body[:merge_method] = merge_method if merge_method
|
33
|
+
body[:sha] = sha if sha
|
34
|
+
|
35
|
+
# Build the path
|
36
|
+
path = "/repos/#{repo_owner}/#{repo_name}/pulls/#{pull_number}/merge"
|
37
|
+
|
38
|
+
UI.message("Merging 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,
|
43
|
+
method: :put,
|
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
|
+
UI.success("Successfully merged pull request ##{pull_number}")
|
57
|
+
else
|
58
|
+
UI.error("Error merging pull request: #{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_MERGE_PULL_STATUS_CODE] = status_code
|
66
|
+
Actions.lane_context[SharedValues::GITHUB_MERGE_PULL_RESPONSE] = response[:body]
|
67
|
+
Actions.lane_context[SharedValues::GITHUB_MERGE_PULL_JSON] = json_response
|
68
|
+
|
69
|
+
return result
|
70
|
+
end
|
71
|
+
|
72
|
+
#####################################################
|
73
|
+
# @!group Documentation
|
74
|
+
#####################################################
|
75
|
+
|
76
|
+
def description
|
77
|
+
"Merge a pull request"
|
78
|
+
end
|
79
|
+
|
80
|
+
def details
|
81
|
+
[
|
82
|
+
"Merges a pull request into the base branch.",
|
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/pulls/pulls#merge-a-pull-request"
|
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: :pull_number,
|
114
|
+
env_name: "GITHUB_API_PULL_NUMBER",
|
115
|
+
description: "The number of the pull request",
|
116
|
+
optional: false,
|
117
|
+
type: Integer),
|
118
|
+
FastlaneCore::ConfigItem.new(key: :commit_title,
|
119
|
+
env_name: "GITHUB_API_COMMIT_TITLE",
|
120
|
+
description: "Title for the automatic commit message",
|
121
|
+
optional: true,
|
122
|
+
type: String),
|
123
|
+
FastlaneCore::ConfigItem.new(key: :commit_message,
|
124
|
+
env_name: "GITHUB_API_COMMIT_MESSAGE",
|
125
|
+
description: "Extra detail to append to automatic commit message",
|
126
|
+
optional: true,
|
127
|
+
type: String),
|
128
|
+
FastlaneCore::ConfigItem.new(key: :merge_method,
|
129
|
+
env_name: "GITHUB_API_MERGE_METHOD",
|
130
|
+
description: "Merge method to use: merge, squash, or rebase",
|
131
|
+
optional: true,
|
132
|
+
type: String,
|
133
|
+
default_value: "merge",
|
134
|
+
verify_block: proc do |value|
|
135
|
+
UI.user_error!("Merge method must be one of: merge, squash, rebase") unless ['merge', 'squash', 'rebase'].include?(value)
|
136
|
+
end),
|
137
|
+
FastlaneCore::ConfigItem.new(key: :sha,
|
138
|
+
env_name: "GITHUB_API_SHA",
|
139
|
+
description: "SHA that pull request head must match to allow merge",
|
140
|
+
optional: true,
|
141
|
+
type: String)
|
142
|
+
]
|
143
|
+
end
|
144
|
+
|
145
|
+
def output
|
146
|
+
[
|
147
|
+
['GITHUB_MERGE_PULL_STATUS_CODE', 'The status code returned by the GitHub API'],
|
148
|
+
['GITHUB_MERGE_PULL_RESPONSE', 'The full response body returned by the GitHub API'],
|
149
|
+
['GITHUB_MERGE_PULL_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 is_supported?(platform)
|
162
|
+
true
|
163
|
+
end
|
164
|
+
|
165
|
+
def example_code
|
166
|
+
[
|
167
|
+
'github_merge_pull(
|
168
|
+
repo_owner: "octocat",
|
169
|
+
repo_name: "Hello-World",
|
170
|
+
pull_number: 42
|
171
|
+
)',
|
172
|
+
'merged_pull = github_merge_pull(
|
173
|
+
repo_owner: "octocat",
|
174
|
+
repo_name: "Hello-World",
|
175
|
+
pull_number: 42,
|
176
|
+
commit_title: "Merge pull request #42 from octocat/feature-branch",
|
177
|
+
commit_message: "This adds the new feature",
|
178
|
+
merge_method: "squash",
|
179
|
+
sha: "6dcb09b5b57875f334f61aebed695e2e4193db5e"
|
180
|
+
)
|
181
|
+
|
182
|
+
message = merged_pull[:json]["message"]
|
183
|
+
sha = merged_pull[:json]["sha"]
|
184
|
+
puts "Merge commit message: #{message}"
|
185
|
+
puts "Merge commit SHA: #{sha}"'
|
186
|
+
]
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
@@ -0,0 +1,160 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/github_api_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
module SharedValues
|
7
|
+
GITHUB_REMOVE_ALL_LABELS_RESPONSE = :GITHUB_REMOVE_ALL_LABELS_RESPONSE
|
8
|
+
GITHUB_REMOVE_ALL_LABELS_JSON = :GITHUB_REMOVE_ALL_LABELS_JSON
|
9
|
+
GITHUB_REMOVE_ALL_LABELS_STATUS_CODE = :GITHUB_REMOVE_ALL_LABELS_STATUS_CODE
|
10
|
+
end
|
11
|
+
|
12
|
+
class GithubRemoveAllLabelsAction < 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
|
+
issue_number = params[:issue_number]
|
19
|
+
server_url = params[:server_url]
|
20
|
+
|
21
|
+
# Validate parameters (additional validation beyond what's in ConfigItem)
|
22
|
+
UI.user_error!("No GitHub issue number given, pass using `issue_number: 123`") unless issue_number.to_s.length > 0
|
23
|
+
|
24
|
+
# Prepare request parameters
|
25
|
+
path = "/repos/#{repo_owner}/#{repo_name}/issues/#{issue_number}/labels"
|
26
|
+
|
27
|
+
# Make the request
|
28
|
+
UI.message("Removing all labels from issue ##{issue_number} in #{repo_owner}/#{repo_name}")
|
29
|
+
response = Helper::GithubApiHelper.github_api_request(
|
30
|
+
token: token,
|
31
|
+
path: path,
|
32
|
+
method: :delete,
|
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.is_a?(Hash) && 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
|
+
UI.success("Successfully removed all labels from issue ##{issue_number}")
|
56
|
+
|
57
|
+
# Set the shared values
|
58
|
+
Actions.lane_context[SharedValues::GITHUB_REMOVE_ALL_LABELS_STATUS_CODE] = status_code
|
59
|
+
Actions.lane_context[SharedValues::GITHUB_REMOVE_ALL_LABELS_RESPONSE] = response
|
60
|
+
Actions.lane_context[SharedValues::GITHUB_REMOVE_ALL_LABELS_JSON] = response
|
61
|
+
|
62
|
+
return result
|
63
|
+
end
|
64
|
+
|
65
|
+
#####################################################
|
66
|
+
# @!group Documentation
|
67
|
+
#####################################################
|
68
|
+
|
69
|
+
def description
|
70
|
+
"Removes all labels from a GitHub issue"
|
71
|
+
end
|
72
|
+
|
73
|
+
def details
|
74
|
+
[
|
75
|
+
"This action removes all labels from a specific issue in a GitHub repository.",
|
76
|
+
"It requires a valid GitHub API token with appropriate permissions.",
|
77
|
+
"Documentation: [https://docs.github.com/en/rest/issues/labels](https://docs.github.com/en/rest/issues/labels#remove-all-labels-from-an-issue)"
|
78
|
+
].join("\n")
|
79
|
+
end
|
80
|
+
|
81
|
+
def available_options
|
82
|
+
[
|
83
|
+
FastlaneCore::ConfigItem.new(key: :api_token,
|
84
|
+
env_name: "GITHUB_API_TOKEN",
|
85
|
+
description: "GitHub API token with repo permissions",
|
86
|
+
optional: false,
|
87
|
+
type: String,
|
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: "Repository owner (organization or username)",
|
102
|
+
optional: false,
|
103
|
+
type: String,
|
104
|
+
verify_block: proc do |value|
|
105
|
+
UI.user_error!("No repository owner provided, pass using `repo_owner: 'owner'`") if value.to_s.empty?
|
106
|
+
end),
|
107
|
+
FastlaneCore::ConfigItem.new(key: :repo_name,
|
108
|
+
env_name: "GITHUB_API_REPO_NAME",
|
109
|
+
description: "Repository name",
|
110
|
+
optional: false,
|
111
|
+
type: String,
|
112
|
+
verify_block: proc do |value|
|
113
|
+
UI.user_error!("No repository name provided, pass using `repo_name: 'name'`") if value.to_s.empty?
|
114
|
+
end),
|
115
|
+
FastlaneCore::ConfigItem.new(key: :issue_number,
|
116
|
+
env_name: "GITHUB_API_ISSUE_NUMBER",
|
117
|
+
description: "The issue number to remove labels from",
|
118
|
+
optional: false,
|
119
|
+
type: Integer)
|
120
|
+
]
|
121
|
+
end
|
122
|
+
|
123
|
+
def output
|
124
|
+
[
|
125
|
+
['GITHUB_REMOVE_ALL_LABELS_STATUS_CODE', 'The status code returned from the GitHub API'],
|
126
|
+
['GITHUB_REMOVE_ALL_LABELS_RESPONSE', 'The full response from the GitHub API'],
|
127
|
+
['GITHUB_REMOVE_ALL_LABELS_JSON', 'The JSON data returned from the GitHub API']
|
128
|
+
]
|
129
|
+
end
|
130
|
+
|
131
|
+
def return_value
|
132
|
+
"A hash including the HTTP status code (:status), the response body (:body), and the parsed JSON (:json)."
|
133
|
+
end
|
134
|
+
|
135
|
+
def authors
|
136
|
+
["crazymanish"]
|
137
|
+
end
|
138
|
+
|
139
|
+
def example_code
|
140
|
+
[
|
141
|
+
'github_remove_all_labels(
|
142
|
+
api_token: ENV["GITHUB_API_TOKEN"],
|
143
|
+
repo_owner: "fastlane",
|
144
|
+
repo_name: "fastlane",
|
145
|
+
issue_number: 123
|
146
|
+
)'
|
147
|
+
]
|
148
|
+
end
|
149
|
+
|
150
|
+
def category
|
151
|
+
:source_control
|
152
|
+
end
|
153
|
+
|
154
|
+
def is_supported?(platform)
|
155
|
+
true
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|