-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathSlackTask.php
More file actions
52 lines (42 loc) · 1.41 KB
/
SlackTask.php
File metadata and controls
52 lines (42 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
namespace Hypernode\Deploy\Deployer\Task\After;
use Deployer\Task\Task;
use Hypernode\Deploy\Deployer\RecipeLoader;
use Hypernode\Deploy\Deployer\Task\ConfigurableTaskInterface;
use Hypernode\Deploy\Deployer\Task\TaskBase;
use Hypernode\DeployConfiguration\AfterDeployTask\SlackWebhook;
use Hypernode\DeployConfiguration\TaskConfigurationInterface;
use function Hypernode\Deploy\Deployer\after;
use function Hypernode\Deploy\Deployer\before;
use function Deployer\set;
class SlackTask extends TaskBase implements ConfigurableTaskInterface
{
/**
* @var RecipeLoader
*/
private $recipeLoader;
public function __construct(RecipeLoader $recipeLoader)
{
$this->recipeLoader = $recipeLoader;
}
public function supports(TaskConfigurationInterface $config): bool
{
return $config instanceof SlackWebhook;
}
/**
* @param TaskConfigurationInterface|SlackWebhook $config
*/
public function configureWithTaskConfig(TaskConfigurationInterface $config): ?Task
{
$this->recipeLoader->load('../contrib/slack.php');
set('slack_webhook', $config->getWebHook());
set('slack_text', '{{release_message}}');
return null;
}
public function register(): void
{
before('deploy', 'slack:notify');
after('deploy:success', 'slack:notify:success');
after('deploy:failed', 'slack:notify:failure');
}
}