Class: Fastlane::Actions::PrCommentAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::PrCommentAction
- Defined in:
- lib/fastlane/plugin/stream_actions/actions/pr_comment.rb
Documentation collapse
Class Method Summary collapse
Class Method Details
.available_options ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/fastlane/plugin/stream_actions/actions/pr_comment.rb', line 34 def self. [ FastlaneCore::ConfigItem.new( env_name: 'GITHUB_PR_NUM', key: :pr_num, description: 'GitHub PR number', optional: true ), FastlaneCore::ConfigItem.new( key: :text, description: 'Comment text', is_string: true, verify_block: proc do |text| UI.user_error!("Text should not be empty") if text.to_s.empty? end ), FastlaneCore::ConfigItem.new( key: :edit_last_comment_with_text, description: 'If last comment contains this text it will be edited', is_string: true, optional: true ) ] end |
.description ⇒ Object
30 31 32 |
# File 'lib/fastlane/plugin/stream_actions/actions/pr_comment.rb', line 30 def self.description 'Comment in the PR' end |
.is_supported?(platform) ⇒ Boolean
59 60 61 |
# File 'lib/fastlane/plugin/stream_actions/actions/pr_comment.rb', line 59 def self.is_supported?(platform) true end |
.run(params) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/fastlane/plugin/stream_actions/actions/pr_comment.rb', line 4 def self.run(params) if params[:pr_num].to_s.empty? UI.important('Skipping the PR comment.') else additional_args = [] if params[:edit_last_comment_with_text] UI.('Checking last comment for required pattern.') = sh("gh pr view #{params[:pr_num]} --json comments --jq '.comments | group_by(.author.login) | map(last)'") required_edition = params[:edit_last_comment_with_text] last_comment_match = required_edition && JSON.parse().any? { |comment| comment['body'].include?(required_edition) } if last_comment_match additional_args << '--edit-last' else UI.important('Last comment does not match the pattern.') end end sh("gh pr comment #{params[:pr_num]} -b '#{params[:text]}' #{additional_args.join(' ')}") UI.success('PR comment been added.') end end |