-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
392 additions
and
58 deletions.
There are no files selected for viewing
97 changes: 97 additions & 0 deletions
97
lib/fastlane/plugin/ddg_apple_automation/actions/mattermost_send_message_action.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
require "fastlane/action" | ||
require "fastlane_core/configuration/config_item" | ||
require "yaml" | ||
require "httparty" | ||
require "json" | ||
require_relative "../helper/ddg_apple_automation_helper" | ||
|
||
module Fastlane | ||
module Actions | ||
class MattermostSendMessageAction < Action | ||
def self.run(params) | ||
github_handle = params[:github_handle] | ||
template_name = params[:template_name] | ||
mm_webhook_url = params[:mattermost_webhook_url] | ||
args = (params[:template_args] || {}).merge(Hash(ENV).transform_keys { |key| key.downcase.gsub('-', '_') }) | ||
mapping_file = Helper::DdgAppleAutomationHelper.path_for_asset_file("mattermost_send_message/github-mattermost-user-id-mapping.yml") | ||
user_mapping = YAML.load_file(mapping_file) | ||
mattermost_user_handle = user_mapping[github_handle] | ||
|
||
if mattermost_user_handle.nil? || mattermost_user_handle.to_s.empty? | ||
UI.message("Mattermost user handle not known for #{github_handle}, skipping sending message") | ||
return | ||
end | ||
|
||
text = process_template(template_name, args) | ||
payload = { | ||
"channel" => mattermost_user_handle, | ||
"username" => "GitHub Actions", | ||
"text" => text, | ||
"icon_url" => "https://duckduckgo.com/assets/logo_header.v108.svg" | ||
} | ||
|
||
response = HTTParty.post(mm_webhook_url, { | ||
headers: { 'Content-Type' => 'application/json' }, | ||
body: payload.to_json | ||
}) | ||
|
||
# Check response status | ||
if response.success? | ||
UI.success("Message sent successfully!") | ||
else | ||
UI.user_error!("Failed to send message: #{response.body}") | ||
end | ||
end | ||
|
||
def self.description | ||
"This action sends a message to Mattermost, reporting the outcome to the user who triggered the workflow" | ||
end | ||
|
||
def self.authors | ||
["DuckDuckGo"] | ||
end | ||
|
||
def self.return_value | ||
"" | ||
end | ||
|
||
def self.details | ||
# Optional: | ||
"" | ||
end | ||
|
||
def self.process_template(template_name, args) | ||
template_file = Helper::DdgAppleAutomationHelper.path_for_asset_file("mattermost_send_message/templates/#{template_name}.txt.erb") | ||
Helper::DdgAppleAutomationHelper.process_erb_template(template_file, args) | ||
end | ||
|
||
def self.available_options | ||
[ | ||
FastlaneCore::ConfigItem.new(key: :mattermost_webhook_url, | ||
env_name: "MM_WEBHOOK_URL", | ||
description: "Mattermost webhook URL", | ||
optional: false, | ||
type: String), | ||
FastlaneCore::ConfigItem.new(key: :github_handle, | ||
description: "Github user handle", | ||
optional: false, | ||
type: String), | ||
FastlaneCore::ConfigItem.new(key: :template_args, | ||
description: "Template arguments. For backward compatibility, environment variables are added to this hash", | ||
optional: true, | ||
type: Hash, | ||
default_value: {}), | ||
FastlaneCore::ConfigItem.new(key: :template_name, | ||
description: "Name of a template file (without extension) for the message. Templates can be found in assets/mattermost_send_message/templates subdirectory. | ||
The file is processed before being posted", | ||
optional: false, | ||
type: String) | ||
] | ||
end | ||
|
||
def self.is_supported?(platform) | ||
true | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
30 changes: 30 additions & 0 deletions
30
...ddg_apple_automation/assets/mattermost_send_message/github-mattermost-user-id-mapping.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
aataraxiaa: "@psmith" | ||
afterxleep: "@dbernal" | ||
alessandroboron: "@aboron" | ||
amddg44: "@amallon" | ||
ayoy: "@dkapusta" | ||
brindy: "@brindy" | ||
bwaresiak: "@bartek" | ||
Bunn: "@fbunn" | ||
dharb: "@dave" | ||
diegoreymendez: "@dreymendez" | ||
dus7: "@mariusz" | ||
federicocappelli: "@fcappelli" | ||
GioSensation: "@emanuele" | ||
graeme: "@garthur" | ||
jaceklyp: "@jlyp" | ||
jonathanKingston: "@jkingston" | ||
jotaemepereira: "@jpereira" | ||
ladamski: "@ladamski" | ||
mallexxx: "@amartemyanov" | ||
miasma13: "@msmaga" | ||
muodov: "@mtsoy" | ||
quanganhdo: "@ado" | ||
samsymons: "@ssymons" | ||
shakyShane: "@sosbourne" | ||
SabrinaTardio: "@stardio" | ||
THISISDINOSAUR: "@esullivan" | ||
tomasstrba: "@tom" | ||
viktorjansson: "@viktor" | ||
vinay-nadig-0042: "@vnadig" | ||
kshann: "@kshannon" |
1 change: 1 addition & 0 deletions
1
.../ddg_apple_automation/assets/mattermost_send_message/templates/ios-release-failed.txt.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
:warning: **iOS release job failed** :thisisfine: | [:github: Workflow run summary](<%= workflow_url %>) |
1 change: 1 addition & 0 deletions
1
...pple_automation/assets/mattermost_send_message/templates/notarized-build-complete.txt.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Notarized macOS app `<%= release_type %>` build is ready :goose_honk_tada: | [:github: Workflow run summary](<%= workflow_url %>)<% if defined?(asana_task_url) && !asana_task_url.to_s.strip.empty? %> | [:asana: Asana Task](<%= asana_task_url %>)<% end %> |
1 change: 1 addition & 0 deletions
1
..._apple_automation/assets/mattermost_send_message/templates/notarized-build-failed.txt.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
:rotating_light: Notarized macOS app `<%= release_type %>` build failed | [:github: Workflow run summary](<%= workflow_url %>)<% if defined?(asana_task_url) && !asana_task_url.to_s.strip.empty? %> | [:asana: Asana Task](<%= asana_task_url %>)<% end %> |
1 change: 1 addition & 0 deletions
1
...apple_automation/assets/mattermost_send_message/templates/public-release-complete.txt.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<%= platform %> app has been successfully uploaded to <%= destination %> :goose_honk_tada: | [:github: Workflow run summary](<%= workflow_url %>) |
1 change: 1 addition & 0 deletions
1
...g_apple_automation/assets/mattermost_send_message/templates/public-release-failed.txt.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
:rotating_light: <%= platform %> app <%= destination %> workflow failed | [:github: Workflow run summary](<%= workflow_url %>) |
1 change: 1 addition & 0 deletions
1
...apple_automation/assets/mattermost_send_message/templates/variants-release-failed.txt.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
:rotating_light: macOS app variants workflow failed | [:github: Workflow run summary](<%= workflow_url %>) |
1 change: 1 addition & 0 deletions
1
...le_automation/assets/mattermost_send_message/templates/variants-release-published.txt.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
macOS app variants have been published successfully :goose_honk_tada: | [:github: Workflow run summary](<%= workflow_url %>) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
module Fastlane | ||
module DdgAppleAutomation | ||
VERSION = "0.11.3" | ||
VERSION = "0.11.7" | ||
end | ||
end |
Oops, something went wrong.