Class: Fastlane::Actions::CommentOnPrAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/wpmreleasetoolkit/actions/common/comment_on_pr.rb

Class Method Summary collapse

Class Method Details

.authorsObject



30
31
32
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/comment_on_pr.rb', line 30

def self.authors
  ['Automattic']
end

.available_optionsObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/comment_on_pr.rb', line 43

def self.available_options
  [
    Fastlane::Helper::GithubHelper.github_token_config_item,
    FastlaneCore::ConfigItem.new(
      key: :reuse_identifier,
      description: 'If provided, the reuse identifier can identify an existing comment to overwrite',
      type: String,
      default_value: nil
    ),
    FastlaneCore::ConfigItem.new(
      key: :project,
      description: 'The project slug (ex: `wordpress-mobile/wordpress-ios`)',
      type: String
    ),
    FastlaneCore::ConfigItem.new(
      key: :pr_number,
      description: 'The PR number',
      type: Integer
    ),
    FastlaneCore::ConfigItem.new(
      key: :body,
      description: 'The content of the comment',
      type: String
    ),
  ]
end

.descriptionObject



26
27
28
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/comment_on_pr.rb', line 26

def self.description
  'Post a comment on a given PR number (optionally updating an existing one)'
end

.detailsObject



34
35
36
37
38
39
40
41
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/comment_on_pr.rb', line 34

def self.details
  <<~DETAILS
    If used just once, this method makes it nice and easy to post a quick comment to a GitHub PR.

    Subsequent runs will allow you to update an existing comment as many times as you need to
    (e.g. across multiple CI runs), by using a `:reuse_identifier` to identify the comment to update.
  DETAILS
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


80
81
82
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/comment_on_pr.rb', line 80

def self.is_supported?(platform)
  true
end

.outputObject



70
71
72
73
74
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/comment_on_pr.rb', line 70

def self.output
  [
    ['PR_COMMENT_REUSE_IDENTIFIER', 'The `reuse_identifier` for the most recently posted comment'],
  ]
end

.return_valueObject



76
77
78
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/comment_on_pr.rb', line 76

def self.return_value
  'The `reuse_identifier` for the posted comment (useful for updating it later, if needed)'
end

.run(params) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/comment_on_pr.rb', line 10

def self.run(params)
  require_relative '../../helper/github_helper'

  github_helper = Fastlane::Helper::GithubHelper.new(github_token: params[:github_token])
  reuse_identifier = github_helper.comment_on_pr(
    project_slug: params[:project],
    pr_number: params[:pr_number],
    body: params[:body],
    reuse_identifier: params[:reuse_identifier]
  )

  Actions.lane_context[SharedValues::PR_COMMENT_REUSE_IDENTIFIER] = reuse_identifier

  reuse_identifier
end