phallstrom/slackistrano

Problem with moving webhook url to .env file

strtwtsn opened this issue · 2 comments

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: #<SocketError: getaddrinfo: Name or service not known>

Should this work?

@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.

@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'