Class: Fastlane::Actions::MailgunAction
- Inherits:
-
Fastlane::Action
- Object
- Fastlane::Action
- Fastlane::Actions::MailgunAction
- Defined in:
- lib/fastlane/actions/mailgun.rb
Constant Summary
Constants inherited from Fastlane::Action
Fastlane::Action::AVAILABLE_CATEGORIES
Class Method Summary collapse
- .author ⇒ Object
- .available_options ⇒ Object
- .category ⇒ Object
- .description ⇒ Object
- .example_code ⇒ Object
- .handle_params_transition(options) ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .mail_template(options) ⇒ Object
- .mailgunit(options) ⇒ Object
- .run(options) ⇒ Object
Methods inherited from Fastlane::Action
action_name, authors, details, lane_context, method_missing, other_action, output, return_value, sample_return_value, sh, step_text
Class Method Details
.author ⇒ Object
87 88 89 |
# File 'lib/fastlane/actions/mailgun.rb', line 87 def self. "thiagolioy" end |
.available_options ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/fastlane/actions/mailgun.rb', line 21 def self. [ # This is here just for while due to the transition, not needed anymore FastlaneCore::ConfigItem.new(key: :mailgun_sandbox_domain, env_name: "MAILGUN_SANDBOX_POSTMASTER", optional: true, description: "Mailgun sandbox domain postmaster for your mail. Please use postmaster instead"), # This is here just for while due to the transition, should use postmaster instead FastlaneCore::ConfigItem.new(key: :mailgun_sandbox_postmaster, env_name: "MAILGUN_SANDBOX_POSTMASTER", optional: true, description: "Mailgun sandbox domain postmaster for your mail. Please use postmaster instead"), # This is here just for while due to the transition, should use apikey instead FastlaneCore::ConfigItem.new(key: :mailgun_apikey, env_name: "MAILGUN_APIKEY", optional: true, description: "Mailgun apikey for your mail. Please use postmaster instead"), FastlaneCore::ConfigItem.new(key: :postmaster, env_name: "MAILGUN_SANDBOX_POSTMASTER", description: "Mailgun sandbox domain postmaster for your mail"), FastlaneCore::ConfigItem.new(key: :apikey, env_name: "MAILGUN_APIKEY", description: "Mailgun apikey for your mail"), FastlaneCore::ConfigItem.new(key: :to, env_name: "MAILGUN_TO", description: "Destination of your mail"), FastlaneCore::ConfigItem.new(key: :from, env_name: "MAILGUN_FROM", optional: true, description: "Mailgun sender name", default_value: "Mailgun Sandbox"), FastlaneCore::ConfigItem.new(key: :message, env_name: "MAILGUN_MESSAGE", description: "Message of your mail"), FastlaneCore::ConfigItem.new(key: :subject, env_name: "MAILGUN_SUBJECT", description: "Subject of your mail", optional: true, is_string: true, default_value: "fastlane build"), FastlaneCore::ConfigItem.new(key: :success, env_name: "MAILGUN_SUCCESS", description: "Was this build successful? (true/false)", optional: true, default_value: true, is_string: false), FastlaneCore::ConfigItem.new(key: :app_link, env_name: "MAILGUN_APP_LINK", description: "App Release link", optional: false, is_string: true), FastlaneCore::ConfigItem.new(key: :ci_build_link, env_name: "MAILGUN_CI_BUILD_LINK", description: "CI Build Link", optional: true, is_string: true), FastlaneCore::ConfigItem.new(key: :template_path, env_name: "MAILGUN_TEMPLATE_PATH", description: "Mail HTML template", optional: true, is_string: true) ] end |
.category ⇒ Object
153 154 155 |
# File 'lib/fastlane/actions/mailgun.rb', line 153 def self.category :notifications end |
.description ⇒ Object
17 18 19 |
# File 'lib/fastlane/actions/mailgun.rb', line 17 def self.description "Send a success/error message to an email group" end |
.example_code ⇒ Object
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/fastlane/actions/mailgun.rb', line 132 def self.example_code [ 'mailgun( to: "[email protected]", success: true, message: "This is the mail\'s content" )', 'mailgun( postmaster: "MY_POSTMASTER", apikey: "MY_API_KEY", to: "DESTINATION_EMAIL", from: "EMAIL_FROM_NAME", success: true, message: "Mail Body", app_link: "http://www.myapplink.com", ci_build_link: "http://www.mycibuildlink.com", template_path: "HTML_TEMPLATE_PATH" )' ] end |
.handle_params_transition(options) ⇒ Object
91 92 93 94 95 96 97 |
# File 'lib/fastlane/actions/mailgun.rb', line 91 def self.handle_params_transition() [:postmaster] = [:mailgun_sandbox_postmaster] if [:mailgun_sandbox_postmaster] puts "\nUsing :mailgun_sandbox_postmaster is deprecated, please change to :postmaster".yellow if [:mailgun_sandbox_postmaster] [:apikey] = [:mailgun_apikey] if [:mailgun_apikey] puts "\nUsing :mailgun_apikey is deprecated, please change to :apikey".yellow if [:mailgun_apikey] end |
.is_supported?(platform) ⇒ Boolean
6 7 8 |
# File 'lib/fastlane/actions/mailgun.rb', line 6 def self.is_supported?(platform) true end |
.mail_template(options) ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/fastlane/actions/mailgun.rb', line 109 def self.mail_template() hash = { author: Actions., last_commit: Actions., message: [:message], app_link: [:app_link] } hash[:success] = [:success] hash[:ci_build_link] = [:ci_build_link] # grabs module eth = Fastlane::ErbTemplateHelper # create html from template html_template_path = [:template_path] if html_template_path && File.exist?(html_template_path) html_template = eth.load_from_path(html_template_path) else html_template = eth.load("mailgun_html_template") end eth.render(html_template, hash) end |
.mailgunit(options) ⇒ Object
99 100 101 102 103 104 105 106 107 |
# File 'lib/fastlane/actions/mailgun.rb', line 99 def self.mailgunit() sandbox_domain = [:postmaster].split("@").last RestClient.post "https://api:#{[:apikey]}@api.mailgun.net/v3/#{sandbox_domain}/messages", from: "#{[:from]}<#{[:postmaster]}>", to: ([:to]).to_s, subject: [:subject], html: mail_template() mail_template() end |
.run(options) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/fastlane/actions/mailgun.rb', line 10 def self.run() Actions.verify_gem!('rest-client') require 'rest-client' handle_params_transition() mailgunit() end |