Skip to content

Added options for picture, and notification about beginning deploy #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ Add variable to your stage

```ruby
set :mls_ruby_capistrano_slacker_webhook_url, ENV.fetch('CAPISTANO_SLACKER_WEBHOOK_URL')

set :mls_ruby_capistrano_slacker_display_display_random_picture, true # Default value false

set :mls_ruby_capistrano_slacker_notify_about_beginning, true # Default value false
```

### mls_ruby_gitlab_private_token
Expand Down
35 changes: 19 additions & 16 deletions lib/capistrano/tasks/mls_ruby_capistrano_slacker.rake
Original file line number Diff line number Diff line change
Expand Up @@ -124,24 +124,23 @@ namespace :mls_ruby_capistrano_slacker do
puts 'ⓂⓁⓈ-ⓉⒺⒸ [🛠] [mls_ruby_capistrano_slacker] :: [ℹ️] notify_about_beginning'

on roles(:all) do |host|
options = {
color: 'warning',
fallback: 'New deploy has began',
text: '_New deploy has began_',
author_name: ENV.fetch('GITLAB_USER_NAME'),
author_link: "https://#{ URI.parse( ENV.fetch('CI_API_V4_URL') ).host }/users/#{ ENV.fetch('GITLAB_USER_LOGIN') }",
author_icon: author_icon,
fields: fetch(:mls_ruby_slack_attachment_fields),
footer: fetch(:mls_ruby_github_url_to_the_project),
footer_ico: fetch(:mls_ruby_github_mls_logo),
ts: Time.now.to_i
}
options.merge(image_url: image_url) if fetch(:mls_ruby_capistrano_slacker_display_display_random_picture)
Slack::Notifier.new(
fetch(:mls_ruby_capistrano_slacker_webhook_url),
username: 'CapistranoSlacker',
icon_emoji: ':ghost:').post text: '', attachments: [
{
color: 'warning',
fallback: 'New deploy has began',
text: '_New deploy has began_',
author_name: ENV.fetch('GITLAB_USER_NAME'),
author_link: "https://#{ URI.parse( ENV.fetch('CI_API_V4_URL') ).host }/users/#{ ENV.fetch('GITLAB_USER_LOGIN') }",
author_icon: author_icon,
image_url: image_url,
fields: fetch(:mls_ruby_slack_attachment_fields),
footer: fetch(:mls_ruby_github_url_to_the_project),
footer_ico: fetch(:mls_ruby_github_mls_logo),
ts: Time.now.to_i
}
]
icon_emoji: ':ghost:').post text: '', attachments: [options]
end
end

Expand Down Expand Up @@ -200,7 +199,9 @@ namespace :mls_ruby_capistrano_slacker do
end
end

before 'deploy:starting', 'mls_ruby_capistrano_slacker:notify_about_beginning'
if fetch(:mls_ruby_capistrano_slacker_notify_about_beginning)
before 'deploy:starting', 'mls_ruby_capistrano_slacker:notify_about_beginning'
end
after 'deploy:failed', 'mls_ruby_capistrano_slacker:notify_failed'
after 'deploy:finished', 'mls_ruby_capistrano_slacker:notify_finished'
end
Expand All @@ -211,6 +212,8 @@ namespace :load do
set :mls_ruby_github_url_to_the_project, '<https://github.com/MLSDev/mls_ruby_capistrano_slacker|mls_ruby_capistrano_slacker>'
set :mls_ruby_github_mls_logo, 'https://avatars2.githubusercontent.com/u/1436035?s=50&v=4'
set :mls_ruby_capistrano_slacker_post_release_description, false
set :mls_ruby_capistrano_slacker_display_display_random_picture, false
set :mls_ruby_capistrano_slacker_notify_about_beginning, false
set :mls_ruby_gitlab_private_token, ENV['GITLAB__PRIVATE_TOKEN']
set :mls_ruby_slack_attachment_fields, -> {
slack_attachment_fields__job = {
Expand Down