Class: Fastlane::Actions::CreatePullRequestAction
- Inherits:
-
Fastlane::Action
- Object
- Fastlane::Action
- Fastlane::Actions::CreatePullRequestAction
- Defined in:
- fastlane/lib/fastlane/actions/create_pull_request.rb
Constant Summary
Constants inherited from Fastlane::Action
Fastlane::Action::AVAILABLE_CATEGORIES, Fastlane::Action::RETURN_TYPES
Documentation collapse
- .author ⇒ Object
- .available_options ⇒ Object
- .category ⇒ Object
- .description ⇒ Object
- .example_code ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .return_value ⇒ Object
Class Method Summary collapse
Methods inherited from Fastlane::Action
action_name, authors, deprecated_notes, details, lane_context, method_missing, other_action, output, return_type, sample_return_value, shell_out_should_use_bundle_exec?, step_text
Class Method Details
.author ⇒ Object
99 100 101 |
# File 'fastlane/lib/fastlane/actions/create_pull_request.rb', line 99 def self. ["seei", "tommeier"] end |
.available_options ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'fastlane/lib/fastlane/actions/create_pull_request.rb', line 49 def self. [ FastlaneCore::ConfigItem.new(key: :api_token, env_name: "GITHUB_PULL_REQUEST_API_TOKEN", description: "Personal API Token for GitHub - generate one at https://github.com/settings/tokens", sensitive: true, code_gen_sensitive: true, default_value: ENV["GITHUB_API_TOKEN"], default_value_dynamic: true, is_string: true, optional: false), FastlaneCore::ConfigItem.new(key: :repo, env_name: "GITHUB_PULL_REQUEST_REPO", description: "The name of the repository you want to submit the pull request to", is_string: true, optional: false), FastlaneCore::ConfigItem.new(key: :title, env_name: "GITHUB_PULL_REQUEST_TITLE", description: "The title of the pull request", is_string: true, optional: false), FastlaneCore::ConfigItem.new(key: :body, env_name: "GITHUB_PULL_REQUEST_BODY", description: "The contents of the pull request", is_string: true, 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, code_gen_sensitive: true, default_value: Actions.git_branch, default_value_dynamic: true, optional: true), FastlaneCore::ConfigItem.new(key: :base, env_name: "GITHUB_PULL_REQUEST_BASE", description: "The name of the branch you want your changes pulled into (defaults to `master`)", is_string: true, default_value: 'master', optional: true), FastlaneCore::ConfigItem.new(key: :api_url, env_name: "GITHUB_PULL_REQUEST_API_URL", description: "The URL of GitHub API - used when the Enterprise (default to `https://api.github.com`)", is_string: true, code_gen_default_value: 'https://api.github.com', default_value: 'https://api.github.com', optional: true) ] end |
.category ⇒ Object
125 126 127 |
# File 'fastlane/lib/fastlane/actions/create_pull_request.rb', line 125 def self.category :source_control end |
.description ⇒ Object
45 46 47 |
# File 'fastlane/lib/fastlane/actions/create_pull_request.rb', line 45 def self.description "This will create a new pull request on GitHub" end |
.example_code ⇒ Object
111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'fastlane/lib/fastlane/actions/create_pull_request.rb', line 111 def self.example_code [ 'create_pull_request( api_token: "secret", # optional, defaults to ENV["GITHUB_API_TOKEN"] repo: "fastlane/fastlane", title: "Amazing new feature", head: "my-feature", # optional, defaults to current branch name base: "master", # optional, defaults to "master" body: "Please pull this in!", # optional api_url: "http://yourdomain/api/v3" # optional, for GitHub Enterprise, defaults to "https://api.github.com" )' ] end |
.is_supported?(platform) ⇒ Boolean
103 104 105 |
# File 'fastlane/lib/fastlane/actions/create_pull_request.rb', line 103 def self.is_supported?(platform) return true end |
.return_value ⇒ Object
107 108 109 |
# File 'fastlane/lib/fastlane/actions/create_pull_request.rb', line 107 def self.return_value "The parsed JSON when successful" end |
.run(params) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'fastlane/lib/fastlane/actions/create_pull_request.rb', line 8 def self.run(params) UI.("Creating new pull request from '#{params[:head]}' to branch '#{params[:base]}' of '#{params[:repo]}'") payload = { 'title' => params[:title], 'head' => params[:head], 'base' => params[:base] } payload['body'] = params[:body] if params[:body] GithubApiAction.run( server_url: params[:api_url], api_token: params[:api_token], http_method: 'POST', path: "repos/#{params[:repo]}/pulls", body: payload, error_handlers: { '*' => proc do |result| UI.error("GitHub responded with #{result[:status]}: #{result[:body]}") return nil end } ) do |result| json = result[:json] number = json['number'] html_url = json['html_url'] UI.success("Successfully created pull request ##{number}. You can see it at '#{html_url}'") Actions.lane_context[SharedValues::CREATE_PULL_REQUEST_HTML_URL] = html_url return html_url end end |