Created
March 29, 2019 02:25
-
-
Save gaussbeam/eec123391e88231ce6757ed9accd58df to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Fastlane | |
module Actions | |
class GetIssuesWithMilestoneAction < Action | |
def self.run(params) | |
UI.message("Getting issues on GitHub (#{params[:server_url]}/#{params[:url]} | with milestone: \##{params[:milestone_number]}, state:#{params[:state]})") | |
GithubApiAction.run( | |
server_url: params[:server_url], | |
api_token: params[:api_token], | |
http_method: "GET", | |
path: "repos/#{params[:url]}/issues?milestone=#{params[:milestone_number]}&state=#{params[:state]}" | |
) do |result| | |
result = result[:json] | |
if result.nil? || result.empty? then | |
UI.important("Issues with milestone \##{params[:milestone_number]}(state: #{params[:state]}) on '#{params[:url]}' does not exist.") | |
return nil | |
else | |
# Found it | |
UI.message("Issues with milestone \##{params[:milestone_number]}(state: #{params[:state]}) exist.") | |
return result | |
end | |
end | |
end | |
##################################################### | |
# @!group Documentation | |
##################################################### | |
def self.description | |
"Return issues on GitHub (only with designated milestone)" | |
end | |
def self.available_options | |
[ | |
FastlaneCore::ConfigItem.new(key: :url, | |
env_name: "FL_GET_GITHUB_RELEASE_URL", | |
description: "The path to your repo, e.g. 'KrauseFx/fastlane'", | |
verify_block: proc do |value| | |
UI.user_error!("Please only pass the path, e.g. 'KrauseFx/fastlane'") if value.include?("github.com") | |
UI.user_error!("Please only pass the path, e.g. 'KrauseFx/fastlane'") if value.split('/').count != 2 | |
end), | |
FastlaneCore::ConfigItem.new(key: :server_url, | |
env_name: "FL_GITHUB_RELEASE_SERVER_URL", | |
description: "The server url. e.g. 'https://your.github.server/api/v3' (Default: 'https://api.github.com')", | |
default_value: "https://api.github.com", | |
optional: true, | |
verify_block: proc do |value| | |
UI.user_error!("Please include the protocol in the server url, e.g. https://your.github.server") unless value.include?("//") | |
end), | |
FastlaneCore::ConfigItem.new(key: :milestone_number, | |
description: "Number of milestone to check. (If you want to get issues with 'github.com/OWNER/REPO/milestone/12', input '12' here.)"), | |
FastlaneCore::ConfigItem.new(key: :state, | |
description: "State of issues to check(Choose from 'open', 'closed', 'all'. Default: 'open')", | |
default_value: "open", | |
verify_block: proc do |value| | |
states = ["open", "closed", "all"] | |
UI.user_error!("Invalid state") unless states.include?(value) | |
end), | |
FastlaneCore::ConfigItem.new(key: :api_token, | |
env_name: "FL_GITHUB_RELEASE_API_TOKEN", | |
sensitive: true, | |
description: "GitHub Personal Token (required for private repositories)") | |
] | |
end | |
def self.is_supported?(platform) | |
true # All platform | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment