fastlane/lib/fastlane/actions/create_pull_request.rb in fastlane-2.140.0 vs fastlane/lib/fastlane/actions/create_pull_request.rb in fastlane-2.141.0

- old
+ new

@@ -41,10 +41,13 @@ add_assignees(params, number) if params[:assignees] # Add reviewers to pull request add_reviewers(params, number) if params[:reviewers] || params[:team_reviewers] + # Add a milestone to pull request + add_milestone(params, number) if params[:milestone] + Actions.lane_context[SharedValues::CREATE_PULL_REQUEST_HTML_URL] = html_url Actions.lane_context[SharedValues::CREATE_PULL_REQUEST_NUMBER] = number return html_url end end @@ -109,10 +112,31 @@ end } ) end + def self.add_milestone(params, number) + payload = {} + if params[:milestone] + payload["milestone"] = params[:milestone] + end + + GithubApiAction.run( + server_url: params[:api_url], + api_token: params[:api_token], + http_method: 'PATCH', + path: "repos/#{params[:repo]}/issues/#{number}", + body: payload, + error_handlers: { + '*' => proc do |result| + UI.error("GitHub responded with #{result[:status]}: #{result[:body]}") + return nil + end + } + ) + end + ##################################################### # @!group Documentation ##################################################### def self.description @@ -154,9 +178,14 @@ optional: true), FastlaneCore::ConfigItem.new(key: :labels, env_name: "GITHUB_PULL_REQUEST_LABELS", description: "The labels for the pull request", type: Array, + optional: true), + FastlaneCore::ConfigItem.new(key: :milestone, + env_name: "GITHUB_PULL_REQUEST_MILESTONE", + description: "The milestone ID (Integer) for the pull request", + type: Numeric, optional: true), FastlaneCore::ConfigItem.new(key: :head, env_name: "GITHUB_PULL_REQUEST_HEAD", description: "The name of the branch where your changes are implemented (defaults to the current branch name)", is_string: true,