Sha256: d2fb9a77bc4f49e9251d972dd825252028041b815c02cf4dae3428a0db5da7a1

Contents?: true

Size: 1.51 KB

Versions: 82

Compression:

Stored size: 1.51 KB

Contents

require "uri"
require "net/http"

namespace :load do
  task :defaults do
    set :slack_token,           -> { "xxx-xxx-xxx-xxx" }
    set :slack_channel,         -> { "xxx-xxx-xxx-xxx" }
    set :slack_text,            -> { "*#{ fetch(:application) }* new Deployment on *#{ fetch(:stage) }* ... check:  #{fetch(:nginx_use_ssl) ? 'https': 'http'}://#{ fetch(:nginx_major_domain) ? fetch(:nginx_major_domain).gsub(/^\*?\./, "") : Array( fetch(:nginx_domains) ).first.gsub(/^\*?\./, "") }" }
    set :slack_username,        -> { "#{ fetch(:application) }-Bot (#{fetch(:stage)})" }
    set :slack_production_icon, -> { "http://icons.iconarchive.com/icons/itzikgur/my-seven/128/Backup-IBM-Server-icon.png" }
    set :slack_staging_icon,    -> { "http://icons.iconarchive.com/icons/oxygen-icons.org/oxygen/128/Mimetypes-application-x-ruby-icon.png" }
  end
end


namespace :deploy do
  
  desc "inform slack about upload"
  task :inform_slack do
    
    params = {  
                    token:      fetch(:slack_token),
                    channel:    fetch(:slack_channel),
                    text:       fetch(:slack_text),
                    parse:      "full",
                    mrkdwn:     true,
                    username:   fetch(:slack_username),
                    icon_url:   "#{ fetch(:stage) == :production ? fetch(:slack_production_icon) : fetch(:slack_staging_icon) }"
              }
    
    Net::HTTP.post_form(URI.parse('https://slack.com/api/chat.postMessage'), params)
    
  end
  
  after :finished, :inform_slack
  
end

Version data entries

82 entries across 82 versions & 1 rubygems

Version Path
magic_recipes_two-0.0.95 lib/capistrano/tasks/inform_slack.rake
magic_recipes_two-0.0.94 lib/capistrano/tasks/inform_slack.rake
magic_recipes_two-0.0.93 lib/capistrano/tasks/inform_slack.rake
magic_recipes_two-0.0.91 lib/capistrano/tasks/inform_slack.rake
magic_recipes_two-0.0.90 lib/capistrano/tasks/inform_slack.rake
magic_recipes_two-0.0.89 lib/capistrano/tasks/inform_slack.rake
magic_recipes_two-0.0.88 lib/capistrano/tasks/inform_slack.rake
magic_recipes_two-0.0.87 lib/capistrano/tasks/inform_slack.rake
magic_recipes_two-0.0.86 lib/capistrano/tasks/inform_slack.rake
magic_recipes_two-0.0.85 lib/capistrano/tasks/inform_slack.rake
magic_recipes_two-0.0.84 lib/capistrano/tasks/inform_slack.rake
magic_recipes_two-0.0.83 lib/capistrano/tasks/inform_slack.rake
magic_recipes_two-0.0.82 lib/capistrano/tasks/inform_slack.rake
magic_recipes_two-0.0.81 lib/capistrano/tasks/inform_slack.rake
magic_recipes_two-0.0.80 lib/capistrano/tasks/inform_slack.rake
magic_recipes_two-0.0.79 lib/capistrano/tasks/inform_slack.rake
magic_recipes_two-0.0.78 lib/capistrano/tasks/inform_slack.rake
magic_recipes_two-0.0.77 lib/capistrano/tasks/inform_slack.rake
magic_recipes_two-0.0.76 lib/capistrano/tasks/inform_slack.rake
magic_recipes_two-0.0.75 lib/capistrano/tasks/inform_slack.rake