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.
Files changed (79) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/README.md +824 -0
  4. data/lib/fastlane/plugin/github_api/actions/github_add_assignees_action.rb +191 -0
  5. data/lib/fastlane/plugin/github_api/actions/github_add_issue_comment_action.rb +184 -0
  6. data/lib/fastlane/plugin/github_api/actions/github_add_labels_action.rb +191 -0
  7. data/lib/fastlane/plugin/github_api/actions/github_api_action.rb +47 -0
  8. data/lib/fastlane/plugin/github_api/actions/github_check_pull_merged_action.rb +152 -0
  9. data/lib/fastlane/plugin/github_api/actions/github_create_commit_comment_reaction_action.rb +168 -0
  10. data/lib/fastlane/plugin/github_api/actions/github_create_issue_action.rb +199 -0
  11. data/lib/fastlane/plugin/github_api/actions/github_create_issue_comment_reaction_action.rb +168 -0
  12. data/lib/fastlane/plugin/github_api/actions/github_create_issue_reaction_action.rb +168 -0
  13. data/lib/fastlane/plugin/github_api/actions/github_create_label_action.rb +194 -0
  14. data/lib/fastlane/plugin/github_api/actions/github_create_milestone_action.rb +199 -0
  15. data/lib/fastlane/plugin/github_api/actions/github_create_pull_action.rb +202 -0
  16. data/lib/fastlane/plugin/github_api/actions/github_create_pull_comment_action.rb +229 -0
  17. data/lib/fastlane/plugin/github_api/actions/github_create_pull_comment_reaction_action.rb +168 -0
  18. data/lib/fastlane/plugin/github_api/actions/github_create_pull_review_action.rb +224 -0
  19. data/lib/fastlane/plugin/github_api/actions/github_create_repository_action.rb +230 -0
  20. data/lib/fastlane/plugin/github_api/actions/github_delete_commit_comment_reaction_action.rb +152 -0
  21. data/lib/fastlane/plugin/github_api/actions/github_delete_issue_comment_action.rb +153 -0
  22. data/lib/fastlane/plugin/github_api/actions/github_delete_issue_comment_reaction_action.rb +152 -0
  23. data/lib/fastlane/plugin/github_api/actions/github_delete_issue_reaction_action.rb +152 -0
  24. data/lib/fastlane/plugin/github_api/actions/github_delete_label_action.rb +164 -0
  25. data/lib/fastlane/plugin/github_api/actions/github_delete_milestone_action.rb +159 -0
  26. data/lib/fastlane/plugin/github_api/actions/github_delete_pull_comment_action.rb +144 -0
  27. data/lib/fastlane/plugin/github_api/actions/github_delete_pull_comment_reaction_action.rb +152 -0
  28. data/lib/fastlane/plugin/github_api/actions/github_delete_repository_action.rb +166 -0
  29. data/lib/fastlane/plugin/github_api/actions/github_dismiss_pull_review_action.rb +168 -0
  30. data/lib/fastlane/plugin/github_api/actions/github_get_issue_action.rb +166 -0
  31. data/lib/fastlane/plugin/github_api/actions/github_get_issue_comment_action.rb +174 -0
  32. data/lib/fastlane/plugin/github_api/actions/github_get_issue_event_action.rb +169 -0
  33. data/lib/fastlane/plugin/github_api/actions/github_get_issue_timeline_action.rb +199 -0
  34. data/lib/fastlane/plugin/github_api/actions/github_get_milestone_action.rb +167 -0
  35. data/lib/fastlane/plugin/github_api/actions/github_get_pull_action.rb +150 -0
  36. data/lib/fastlane/plugin/github_api/actions/github_get_pull_comment_action.rb +147 -0
  37. data/lib/fastlane/plugin/github_api/actions/github_get_pull_review_action.rb +137 -0
  38. data/lib/fastlane/plugin/github_api/actions/github_get_pull_review_comments_action.rb +181 -0
  39. data/lib/fastlane/plugin/github_api/actions/github_list_all_pull_comments_action.rb +186 -0
  40. data/lib/fastlane/plugin/github_api/actions/github_list_commit_comment_reactions_action.rb +183 -0
  41. data/lib/fastlane/plugin/github_api/actions/github_list_issue_comment_reactions_action.rb +183 -0
  42. data/lib/fastlane/plugin/github_api/actions/github_list_issue_comments_action.rb +197 -0
  43. data/lib/fastlane/plugin/github_api/actions/github_list_issue_events_action.rb +191 -0
  44. data/lib/fastlane/plugin/github_api/actions/github_list_issue_labels_action.rb +192 -0
  45. data/lib/fastlane/plugin/github_api/actions/github_list_issue_reactions_action.rb +183 -0
  46. data/lib/fastlane/plugin/github_api/actions/github_list_issues_action.rb +236 -0
  47. data/lib/fastlane/plugin/github_api/actions/github_list_milestones_action.rb +205 -0
  48. data/lib/fastlane/plugin/github_api/actions/github_list_pull_comment_reactions_action.rb +183 -0
  49. data/lib/fastlane/plugin/github_api/actions/github_list_pull_comments_action.rb +203 -0
  50. data/lib/fastlane/plugin/github_api/actions/github_list_pull_commits_action.rb +175 -0
  51. data/lib/fastlane/plugin/github_api/actions/github_list_pull_files_action.rb +174 -0
  52. data/lib/fastlane/plugin/github_api/actions/github_list_pull_reviewers_action.rb +163 -0
  53. data/lib/fastlane/plugin/github_api/actions/github_list_pull_reviews_action.rb +175 -0
  54. data/lib/fastlane/plugin/github_api/actions/github_list_pulls_action.rb +206 -0
  55. data/lib/fastlane/plugin/github_api/actions/github_list_repo_issue_events_action.rb +185 -0
  56. data/lib/fastlane/plugin/github_api/actions/github_list_repo_labels_action.rb +184 -0
  57. data/lib/fastlane/plugin/github_api/actions/github_lock_issue_action.rb +180 -0
  58. data/lib/fastlane/plugin/github_api/actions/github_merge_pull_action.rb +191 -0
  59. data/lib/fastlane/plugin/github_api/actions/github_remove_all_labels_action.rb +160 -0
  60. data/lib/fastlane/plugin/github_api/actions/github_remove_assignees_action.rb +195 -0
  61. data/lib/fastlane/plugin/github_api/actions/github_remove_label_action.rb +172 -0
  62. data/lib/fastlane/plugin/github_api/actions/github_remove_pull_reviewers_action.rb +169 -0
  63. data/lib/fastlane/plugin/github_api/actions/github_request_pull_review_action.rb +169 -0
  64. data/lib/fastlane/plugin/github_api/actions/github_set_labels_action.rb +191 -0
  65. data/lib/fastlane/plugin/github_api/actions/github_submit_pull_comment_action.rb +185 -0
  66. data/lib/fastlane/plugin/github_api/actions/github_submit_pull_review_action.rb +187 -0
  67. data/lib/fastlane/plugin/github_api/actions/github_unlock_issue_action.rb +157 -0
  68. data/lib/fastlane/plugin/github_api/actions/github_update_issue_action.rb +202 -0
  69. data/lib/fastlane/plugin/github_api/actions/github_update_issue_comment_action.rb +172 -0
  70. data/lib/fastlane/plugin/github_api/actions/github_update_label_action.rb +204 -0
  71. data/lib/fastlane/plugin/github_api/actions/github_update_milestone_action.rb +198 -0
  72. data/lib/fastlane/plugin/github_api/actions/github_update_pull_action.rb +191 -0
  73. data/lib/fastlane/plugin/github_api/actions/github_update_pull_branch_action.rb +158 -0
  74. data/lib/fastlane/plugin/github_api/actions/github_update_pull_comment_action.rb +156 -0
  75. data/lib/fastlane/plugin/github_api/actions/github_update_pull_review_action.rb +151 -0
  76. data/lib/fastlane/plugin/github_api/helper/github_api_helper.rb +123 -0
  77. data/lib/fastlane/plugin/github_api/version.rb +5 -0
  78. data/lib/fastlane/plugin/github_api.rb +16 -0
  79. metadata +120 -0
@@ -0,0 +1,153 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/github_api_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ module SharedValues
7
+ GITHUB_DELETE_ISSUE_COMMENT_STATUS_CODE = :GITHUB_DELETE_ISSUE_COMMENT_STATUS_CODE
8
+ GITHUB_DELETE_ISSUE_COMMENT_RESPONSE = :GITHUB_DELETE_ISSUE_COMMENT_RESPONSE
9
+ GITHUB_DELETE_ISSUE_COMMENT_JSON = :GITHUB_DELETE_ISSUE_COMMENT_JSON
10
+ end
11
+
12
+ class GithubDeleteIssueCommentAction < Action
13
+ class << self
14
+ def run(params)
15
+ # Prepare API call parameters
16
+ server_url = params[:server_url]
17
+ api_token = params[:api_token]
18
+ repo_owner = params[:repo_owner]
19
+ repo_name = params[:repo_name]
20
+ comment_id = params[:comment_id]
21
+
22
+ # Validate parameters
23
+ UI.user_error!("No comment ID provided, pass using `comment_id: 12345678`") unless comment_id.to_s.length > 0
24
+
25
+ # Build the path
26
+ path = "/repos/#{repo_owner}/#{repo_name}/issues/comments/#{comment_id}"
27
+
28
+ UI.message("Deleting comment ID: #{comment_id} from #{repo_owner}/#{repo_name}")
29
+ response = Helper::GithubApiHelper.github_api_request(
30
+ token: api_token,
31
+ path: path,
32
+ method: :delete,
33
+ server_url: server_url
34
+ )
35
+
36
+ status_code = response[:status]
37
+ result = {
38
+ status: status_code,
39
+ body: response[:body],
40
+ json: response[:json]
41
+ }
42
+
43
+ if status_code.between?(200, 299) || status_code == 204
44
+ UI.success("Successfully deleted comment ID: #{comment_id} from #{repo_owner}/#{repo_name}")
45
+ else
46
+ UI.error("Error deleting comment: #{status_code}")
47
+ UI.error(response[:body])
48
+ UI.user_error!("GitHub API returned #{status_code}: #{response[:body]}")
49
+ return nil
50
+ end
51
+
52
+ # Store the results in shared values
53
+ Actions.lane_context[SharedValues::GITHUB_DELETE_ISSUE_COMMENT_STATUS_CODE] = status_code
54
+ Actions.lane_context[SharedValues::GITHUB_DELETE_ISSUE_COMMENT_RESPONSE] = response[:body]
55
+ Actions.lane_context[SharedValues::GITHUB_DELETE_ISSUE_COMMENT_JSON] = response[:json]
56
+
57
+ return result
58
+ end
59
+
60
+ #####################################################
61
+ # @!group Documentation
62
+ #####################################################
63
+
64
+ def description
65
+ "Deletes a comment from a GitHub issue"
66
+ end
67
+
68
+ def details
69
+ [
70
+ "Deletes a comment from an issue in a GitHub repository.",
71
+ "You must provide your GitHub Personal token (get one from https://github.com/settings/tokens/new).",
72
+ "API Documentation: https://docs.github.com/en/rest/issues/comments#delete-an-issue-comment"
73
+ ].join("\n")
74
+ end
75
+
76
+ def available_options
77
+ [
78
+ FastlaneCore::ConfigItem.new(key: :api_token,
79
+ env_name: "GITHUB_API_TOKEN",
80
+ description: "GitHub API token",
81
+ optional: false,
82
+ sensitive: true,
83
+ code_gen_sensitive: true,
84
+ default_value: ENV["GITHUB_API_TOKEN"],
85
+ verify_block: proc do |value|
86
+ UI.user_error!("No GitHub API token given, pass using `api_token: 'token'`") if value.to_s.empty?
87
+ end),
88
+ FastlaneCore::ConfigItem.new(key: :server_url,
89
+ env_name: "GITHUB_API_SERVER_URL",
90
+ description: "GitHub API server URL",
91
+ optional: true,
92
+ default_value: "https://api.github.com"),
93
+ FastlaneCore::ConfigItem.new(key: :repo_owner,
94
+ env_name: "GITHUB_API_REPO_OWNER",
95
+ description: "Repository owner (organization or username)",
96
+ optional: false,
97
+ type: String,
98
+ verify_block: proc do |value|
99
+ UI.user_error!("No repository owner provided, pass using `repo_owner: 'owner'`") if value.to_s.empty?
100
+ end),
101
+ FastlaneCore::ConfigItem.new(key: :repo_name,
102
+ env_name: "GITHUB_API_REPO_NAME",
103
+ description: "Repository name",
104
+ optional: false,
105
+ type: String,
106
+ verify_block: proc do |value|
107
+ UI.user_error!("No repository name provided, pass using `repo_name: 'name'`") if value.to_s.empty?
108
+ end),
109
+ FastlaneCore::ConfigItem.new(key: :comment_id,
110
+ description: "The ID of the comment to delete",
111
+ optional: false,
112
+ type: Integer)
113
+ ]
114
+ end
115
+
116
+ def output
117
+ [
118
+ ['GITHUB_DELETE_ISSUE_COMMENT_STATUS_CODE', 'The status code returned from the GitHub API'],
119
+ ['GITHUB_DELETE_ISSUE_COMMENT_RESPONSE', 'The full response body from the GitHub API'],
120
+ ['GITHUB_DELETE_ISSUE_COMMENT_JSON', 'The parsed JSON returned from the GitHub API']
121
+ ]
122
+ end
123
+
124
+ def return_value
125
+ "A hash including the HTTP status code (:status), the response body (:body), and the parsed JSON (:json)."
126
+ end
127
+
128
+ def authors
129
+ ["crazymanish"]
130
+ end
131
+
132
+ def example_code
133
+ [
134
+ 'github_delete_issue_comment(
135
+ api_token: ENV["GITHUB_API_TOKEN"],
136
+ repo_owner: "fastlane",
137
+ repo_name: "fastlane",
138
+ comment_id: 12345678
139
+ )'
140
+ ]
141
+ end
142
+
143
+ def category
144
+ :source_control
145
+ end
146
+
147
+ def is_supported?(platform)
148
+ true
149
+ end
150
+ end
151
+ end
152
+ end
153
+ 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_ISSUE_COMMENT_REACTION_STATUS_CODE = :GITHUB_DELETE_ISSUE_COMMENT_REACTION_STATUS_CODE
8
+ GITHUB_DELETE_ISSUE_COMMENT_REACTION_RESPONSE = :GITHUB_DELETE_ISSUE_COMMENT_REACTION_RESPONSE
9
+ end
10
+
11
+ class GithubDeleteIssueCommentReactionAction < 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}/issues/comments/#{comment_id}/reactions/#{reaction_id}"
24
+
25
+ UI.message("Deleting reaction ##{reaction_id} for issue 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 issue 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_ISSUE_COMMENT_REACTION_STATUS_CODE] = status_code
51
+ Actions.lane_context[SharedValues::GITHUB_DELETE_ISSUE_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 an issue comment"
62
+ end
63
+
64
+ def details
65
+ [
66
+ "Deletes a reaction from an issue 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-an-issue-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 API 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 issue 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_ISSUE_COMMENT_REACTION_STATUS_CODE', 'The status code returned by the GitHub API'],
113
+ ['GITHUB_DELETE_ISSUE_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_issue_comment_reaction(
132
+ repo_owner: "octocat",
133
+ repo_name: "Hello-World",
134
+ comment_id: 123,
135
+ reaction_id: 456
136
+ )',
137
+ 'result = github_delete_issue_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
@@ -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_ISSUE_REACTION_STATUS_CODE = :GITHUB_DELETE_ISSUE_REACTION_STATUS_CODE
8
+ GITHUB_DELETE_ISSUE_REACTION_RESPONSE = :GITHUB_DELETE_ISSUE_REACTION_RESPONSE
9
+ end
10
+
11
+ class GithubDeleteIssueReactionAction < 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
+ issue_number = params[:issue_number]
20
+ reaction_id = params[:reaction_id]
21
+
22
+ # Build the path
23
+ path = "/repos/#{repo_owner}/#{repo_name}/issues/#{issue_number}/reactions/#{reaction_id}"
24
+
25
+ UI.message("Deleting reaction ##{reaction_id} for issue ##{issue_number} 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 issue ##{issue_number}")
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_ISSUE_REACTION_STATUS_CODE] = status_code
51
+ Actions.lane_context[SharedValues::GITHUB_DELETE_ISSUE_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 an issue"
62
+ end
63
+
64
+ def details
65
+ [
66
+ "Deletes a reaction from an issue.",
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-an-issue-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 API 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: :issue_number,
98
+ env_name: "GITHUB_API_ISSUE_NUMBER",
99
+ description: "The number of the issue",
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_ISSUE_REACTION_STATUS_CODE', 'The status code returned by the GitHub API'],
113
+ ['GITHUB_DELETE_ISSUE_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_issue_reaction(
132
+ repo_owner: "octocat",
133
+ repo_name: "Hello-World",
134
+ issue_number: 123,
135
+ reaction_id: 456
136
+ )',
137
+ 'result = github_delete_issue_reaction(
138
+ repo_owner: "octocat",
139
+ repo_name: "Hello-World",
140
+ issue_number: 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
@@ -0,0 +1,164 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/github_api_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ module SharedValues
7
+ GITHUB_DELETE_LABEL_RESPONSE = :GITHUB_DELETE_LABEL_RESPONSE
8
+ GITHUB_DELETE_LABEL_JSON = :GITHUB_DELETE_LABEL_JSON
9
+ GITHUB_DELETE_LABEL_STATUS_CODE = :GITHUB_DELETE_LABEL_STATUS_CODE
10
+ end
11
+
12
+ class GithubDeleteLabelAction < 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
+ label_name = params[:name]
19
+ server_url = params[:server_url]
20
+
21
+ # Validate parameters (additional validation beyond what's in ConfigItem)
22
+ UI.user_error!("No label name provided, pass using `name: 'bug'`") if label_name.to_s.empty?
23
+
24
+ # Prepare request parameters
25
+ # URL encode the label name to handle special characters like spaces, etc.
26
+ encoded_label = URI.encode_www_form_component(label_name)
27
+ path = "/repos/#{repo_owner}/#{repo_name}/labels/#{encoded_label}"
28
+
29
+ # Make the request
30
+ UI.message("Deleting label '#{label_name}' from #{repo_owner}/#{repo_name}")
31
+ response = Helper::GithubApiHelper.github_api_request(
32
+ token: token,
33
+ path: path,
34
+ method: :delete,
35
+ server_url: server_url
36
+ )
37
+
38
+ status_code = response.key?('status') ? response['status'] : nil
39
+ result = {
40
+ status: status_code,
41
+ body: response,
42
+ json: response
43
+ }
44
+
45
+ if response.key?('error')
46
+ UI.error("GitHub responded with an error: #{response['error']}")
47
+ UI.user_error!("GitHub API error: #{response['error']}")
48
+ return nil
49
+ end
50
+
51
+ if response.is_a?(Hash) && response['message'] && status_code && status_code >= 400
52
+ UI.error("GitHub API error: #{response['message']}")
53
+ UI.user_error!("GitHub API error: #{response['message']} (Status code: #{status_code})")
54
+ return nil
55
+ end
56
+
57
+ UI.success("Successfully deleted label '#{label_name}' from #{repo_owner}/#{repo_name}")
58
+
59
+ # Set the shared values
60
+ Actions.lane_context[SharedValues::GITHUB_DELETE_LABEL_STATUS_CODE] = status_code
61
+ Actions.lane_context[SharedValues::GITHUB_DELETE_LABEL_RESPONSE] = response
62
+ Actions.lane_context[SharedValues::GITHUB_DELETE_LABEL_JSON] = response
63
+
64
+ return result
65
+ end
66
+
67
+ #####################################################
68
+ # @!group Documentation
69
+ #####################################################
70
+
71
+ def description
72
+ "Deletes a label from a GitHub repository"
73
+ end
74
+
75
+ def details
76
+ [
77
+ "This action deletes a label from a GitHub repository by its name.",
78
+ "It requires a valid GitHub API token with appropriate permissions.",
79
+ "Documentation: [https://docs.github.com/en/rest/issues/labels](https://docs.github.com/en/rest/issues/labels#delete-a-label)"
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
+ type: String,
90
+ sensitive: true,
91
+ code_gen_sensitive: true,
92
+ default_value: ENV["GITHUB_API_TOKEN"],
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: :name,
118
+ description: "The name of the label to delete",
119
+ optional: false,
120
+ type: String,
121
+ verify_block: proc do |value|
122
+ UI.user_error!("No label name provided, pass using `name: 'bug'`") if value.to_s.empty?
123
+ end)
124
+ ]
125
+ end
126
+
127
+ def output
128
+ [
129
+ ['GITHUB_DELETE_LABEL_STATUS_CODE', 'The status code returned from the GitHub API'],
130
+ ['GITHUB_DELETE_LABEL_RESPONSE', 'The full response from the GitHub API'],
131
+ ['GITHUB_DELETE_LABEL_JSON', 'The JSON data returned from the GitHub API']
132
+ ]
133
+ end
134
+
135
+ def return_value
136
+ "A hash including the HTTP status code (:status), the response body (:body), and the parsed JSON (:json)."
137
+ end
138
+
139
+ def authors
140
+ ["crazymanish"]
141
+ end
142
+
143
+ def example_code
144
+ [
145
+ 'github_delete_label(
146
+ api_token: ENV["GITHUB_API_TOKEN"],
147
+ repo_owner: "fastlane",
148
+ repo_name: "fastlane",
149
+ name: "wontfix"
150
+ )'
151
+ ]
152
+ end
153
+
154
+ def category
155
+ :source_control
156
+ end
157
+
158
+ def is_supported?(platform)
159
+ true
160
+ end
161
+ end
162
+ end
163
+ end
164
+ end