Minimalistic slack bot notifier approach for rails apps - useful for capistrano deploy scripts
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
#!/usr/bin/env ruby | |
# frozen_string_literal: true | |
require_relative '../config/boot' | |
require_relative '../config/environment' | |
require 'slack' | |
Slack.configure do |config| | |
config.token = Rails.application.secrets.slack_bot[:token] | |
end | |
slack_channel = Rails.application.secrets.slack_bot[:channel] | |
slack_bot = Slack::Web::Client.new | |
slack_bot.chat_postMessage( | |
channel: slack_channel, | |
text: 'deployed successfully', | |
as_user: true | |
) | |
# secrets.yml | |
=begin | |
:slack_bot: | |
:token: 'sample_token' | |
:channel: '#notifications' | |
=end | |
=begin | |
STEPS | |
1. add gem 'slack-ruby-client' to Gemfile and bundle install | |
2. copy this to bin/slack_notifier.rb | |
3. chmod +x bin/slack_notifier.rb | |
4. set up secrets | |
5. bin/slack_notifier.rb | |
6. see your message on the slack | |
=end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment