Skip to content
This repository has been archived by the owner on Apr 26, 2020. It is now read-only.

Commit

Permalink
Fixed #39
Browse files Browse the repository at this point in the history
  • Loading branch information
oanhnn committed Feb 26, 2016
1 parent 4f21808 commit a806d27
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions recipes/slack.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
* file that was distributed with this source code.
*/

/**
* Get local username
*/
env('local_user', function () {
return trim(run("whoami"));
});

/**
* Notify Slack of successful deployment
*/
Expand All @@ -20,9 +27,14 @@
];

$config = array_merge($defaultConfig, (array) get('slack', []));

$server = \Deployer\Task\Context::get()->getServer()->getConfiguration();
$user = !$server->getUser() ? null : $server->getUser();

$server = \Deployer\Task\Context::get()->getServer();
if ($server instanceof \Deployer\Server\Local) {
$user = env('local_user');
} else {
$user = $server->getConfiguration()->getUser() ? : null;
}

$messagePlaceHolders = [
'{{release_path}}' => env('release_path'),
'{{host}}' => env('server.host'),
Expand All @@ -32,12 +44,8 @@
'{{app_name}}' => isset($config['app']) ? $config['app'] : 'app-name',
];
$config['message'] = strtr($config['message'], $messagePlaceHolders);

if (!is_array($config) ||
!isset($config['token']) ||
!isset($config['team']) ||
!isset($config['channel']))
{

if (!is_array($config) || !isset($config['token']) || !isset($config['team']) || !isset($config['channel'])) {
throw new \RuntimeException("Please configure new slack: set('slack', ['token' => 'xoxp...', 'team' => 'team', 'channel' => '#channel', 'messsage' => 'message to send']);");
}

Expand Down

0 comments on commit a806d27

Please sign in to comment.