Class: Fastlane::Actions::SqCiToolsNotifyAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/sq_ci_tools/actions/sq_ci_tools_notify_action.rb

Class Method Summary collapse

Class Method Details

.authorsObject



61
62
63
# File 'lib/fastlane/plugin/sq_ci_tools/actions/sq_ci_tools_notify_action.rb', line 61

def self.authors
  ['Semen Kologrivov']
end

.available_optionsObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/fastlane/plugin/sq_ci_tools/actions/sq_ci_tools_notify_action.rb', line 40

def self.available_options
  [
    FastlaneCore::ConfigItem.new(
      key: :message,
      description: 'Message to send',
      optional: false,
      type: String
    ),
    FastlaneCore::ConfigItem.new(
      key: :links,
      description: 'Links to the end of message',
      optional: true,
      type: Array
    )
  ]
end

.descriptionObject



32
33
34
# File 'lib/fastlane/plugin/sq_ci_tools/actions/sq_ci_tools_notify_action.rb', line 32

def self.description
  'Send message into a messengers'
end

.detailsObject



36
37
38
# File 'lib/fastlane/plugin/sq_ci_tools/actions/sq_ci_tools_notify_action.rb', line 36

def self.details
  ''
end

.is_supported?(_) ⇒ Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/fastlane/plugin/sq_ci_tools/actions/sq_ci_tools_notify_action.rb', line 65

def self.is_supported?(_)
  true
end

.return_valueObject



57
58
59
# File 'lib/fastlane/plugin/sq_ci_tools/actions/sq_ci_tools_notify_action.rb', line 57

def self.return_value
  ''
end

.run(params) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/fastlane/plugin/sq_ci_tools/actions/sq_ci_tools_notify_action.rb', line 7

def self.run(params)
  message = params[:message]
  links_message = (params[:links] || [])
                  .select { |link| !link[:url].nil? }
                  .map { |link| "#{link[:name] || 'Ссылка'}: #{link[:url]}" }
                  .join("\n\n")

  full_message = "#{message}\n\n#{links_message}"
  begin
    other_action.sq_ci_tools_send_telegram_message(
      message: full_message
    )
  rescue => e
    puts "Send message via Telegram error: #{e.message}"
  end 
  
  begin
    other_action.sq_ci_tools_send_max_message(
      message: full_message
    )
  rescue => e
    puts "Send message via Max error: #{e.message}"
  end 
end