phallstrom / slackistrano

Slack integration for Capistrano deployments.
MIT License
374 stars 74 forks source link

Problem with moving webhook url to .env file #82

Closed strtwtsn closed 6 years ago

strtwtsn commented 6 years ago

I have

set :slackistrano_webhook, ``ENV["SLACK_WEBHOOK"]

in my deploy.rb file and

SLACK_WEBHOOK=http://<webhook_url>

in my .env file but I receive the following error

Error: #

Should this work?

phallstrom commented 6 years ago

@strtwtsn Sorry, I forgot all about this. It should if you are loading that .env file yourself, but Slackistrno won't load an env file on it's own.

alexandrebini commented 6 years ago

@strtwtsn you can do something like this in your config/deploy.rb

set :env_file, ".env.#{fetch(:stage)}"

set :slackistrano, -> {
  { channel: ENV['DEPLOY_NOTIFICATION_CHANNEL'], webhook: ENV['DEPLOY_NOTIFICATION_WEBHOOK'] }
}

namespace :env do
  desc 'Load the stage env file'
  task :load do
    Dotenv.load(fetch(:env_file))
  end
end

invoke 'env:load'