Class: Fastlane::Actions::DiscordAction

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

Class Method Summary collapse

Class Method Details

.authorsObject



50
51
52
# File 'lib/fastlane/plugin/discord/actions/discord_action.rb', line 50

def self.authors
  ["Matheus Gambati"]
end

.available_optionsObject



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
# File 'lib/fastlane/plugin/discord/actions/discord_action.rb', line 63

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :url,
                            env_name: "DISCORD_URL",
                         description: "Discord Webhook URL",
                            optional: false,
                                type: String),
    FastlaneCore::ConfigItem.new(key: :build_number,
                            env_name: "DISCORD_BUILD_NUMBER",
                         description: "New build number",
                            optional: false,
                                type: String),
    FastlaneCore::ConfigItem.new(key: :version,
                            env_name: "DISCORD_VERSION",
                          description: "Version of the build",
                            optional: false,
                                type: String),
    FastlaneCore::ConfigItem.new(key: :app_name,
                            env_name: "DISCORD_APP_NAME",
                         description: "Name of the app",
                            optional: false,
                                type: String),
    FastlaneCore::ConfigItem.new(key: :store,
                            env_name: "DISCORD_STORE",
                         description: "Which app store the app has deployed (ios or android), default is android.",
                            optional: true,
                                type: String)
  ]
end

.descriptionObject



46
47
48
# File 'lib/fastlane/plugin/discord/actions/discord_action.rb', line 46

def self.description
  "Discord integration with Fastlane."
end

.detailsObject



58
59
60
61
# File 'lib/fastlane/plugin/discord/actions/discord_action.rb', line 58

def self.details
  # Optional:
  ""
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


93
94
95
96
97
98
99
# File 'lib/fastlane/plugin/discord/actions/discord_action.rb', line 93

def self.is_supported?(platform)
  # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
  # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
  #
  # [:ios, :mac, :android].include?(platform)
  true
end

.itunes_notification(params) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/fastlane/plugin/discord/actions/discord_action.rb', line 18

def self.itunes_notification(params)
  client = Discordrb::Webhooks::Client.new(url: params[:url])
  client.execute do |builder|
    builder.add_embed do |embed|
      embed.title = params[:app_name]
      embed.colour = 0x3c9b00
      embed.url = "https://itunesconnect.apple.com"
      embed.description = "New build uploaded to iTunes Connect with number **#{params[:build_number]}** and version **#{params[:version]}**. "
      embed.author = Discordrb::Webhooks::EmbedAuthor.new(name: "iTunes Connect", url: "https://itunesconnect.apple.com", icon_url: "https://i.imgur.com/68CyCSp.png")
      embed.timestamp = Time.now
    end
  end
end

.play_notification(params) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/fastlane/plugin/discord/actions/discord_action.rb', line 32

def self.play_notification(params)
  client = Discordrb::Webhooks::Client.new(url: params[:url])
  client.execute do |builder|
    builder.add_embed do |embed|
      embed.title = params[:app_name]
      embed.colour = 0x3c9b00
      embed.url = "https://play.google.com/apps/publish"
      embed.description = "New build uploaded to Google Play with number **#{params[:build_number]}** and version **#{params[:version]}**. "
      embed.author = Discordrb::Webhooks::EmbedAuthor.new(name: "Google Play", url: "https://play.google.com/apps/publish", icon_url: "https://i.imgur.com/yD82bnG.png")
      embed.timestamp = Time.now
    end
  end
end

.return_valueObject



54
55
56
# File 'lib/fastlane/plugin/discord/actions/discord_action.rb', line 54

def self.return_value
  # If your method provides a return value, you can describe here what it does
end

.run(params) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/fastlane/plugin/discord/actions/discord_action.rb', line 8

def self.run(params)
  UI.message("Notifying Discord")

  if params[:store] == 'ios'
    return self.itunes_notification(params)
  end

  self.play_notification(params)
end