-
Notifications
You must be signed in to change notification settings - Fork 1
/
promulgator.rb
44 lines (33 loc) · 1.96 KB
/
promulgator.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
require "mina/slack/promulgator/version"
require "mina/slack/promulgator/helper"
set_default :slack_promulgator_webhook_url, nil
set_default :slack_promulgator_channel, '#general'
set_default :slack_promulgator_name, 'Promulgator'
set_default :slack_promulgator_application_emoji, ':earth_americas:'
set_default :slack_promulgator_success_message_emoji, ':rocket:'
set_default :slack_promulgator_failure_message_emoji, ':boom:'
set_default :slack_promulgator_github_url, Mina::Slack::Promulgator::Helper.default_github_url
namespace :slack do
namespace :promulgator do
task :success do
Mina::Slack::Promulgator::Helper.requirements_check(slack_promulgator_webhook_url)
message = Mina::Slack::Promulgator::Helper.success_message(slack_promulgator_success_message_emoji, repository, slack_promulgator_github_url)
payload = Mina::Slack::Promulgator::Helper.success_payload(message, slack_promulgator_channel, slack_promulgator_name, slack_promulgator_application_emoji)
queue %{
export GIT_HASH=$(cd #{deploy_to}/scm && git rev-parse #{commit || branch})
echo "-----> Posting Deploy Success to Slack #{slack_promulgator_channel}"
curl -X POST --data-urlencode 'payload=#{payload}' #{slack_promulgator_webhook_url}
}
end
task :failure do
Mina::Slack::Promulgator::Helper.requirements_check(slack_promulgator_webhook_url)
message = Mina::Slack::Promulgator::Helper.failure_message(slack_promulgator_failure_message_emoji, repository, slack_promulgator_github_url)
payload = Mina::Slack::Promulgator::Helper.failure_payload(message, slack_promulgator_channel, slack_promulgator_name, slack_promulgator_application_emoji)
queue %{
export GIT_HASH=$(cd #{deploy_to}/scm && git rev-parse #{commit || branch})
echo "-----> Posting Deploy Failure to Slack #{slack_promulgator_channel}"
curl -X POST --data-urlencode 'payload=#{payload}' #{slack_promulgator_webhook_url}
}
end
end
end