forked from deployphp/deployer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hipchat.php
53 lines (41 loc) · 1.38 KB
/
hipchat.php
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
53
<?php
/*
## Installing
Add to your _deploy.php_
```php
require 'contrib/hipchat.php';
```
## Configuration
- `hipchat_token` – Hipchat V1 auth token
- `hipchat_room_id` – Room ID or name
- `hipchat_message` – Deploy message, default is `_{{user}}_ deploying `{{branch}}` to *{{target}}*`
- `hipchat_from` – Default to target
- `hipchat_color` – Message color, default is **green**
- `hipchat_url` – The URL to the message endpoint, default is https://api.hipchat.com/v1/rooms/message
## Usage
Since you should only notify Hipchat room of a successful deployment, the `hipchat:notify` task should be executed right at the end.
```php
after('deploy', 'hipchat:notify');
```
*/
namespace Deployer;
use Deployer\Utility\Httpie;
set('hipchat_color', 'green');
set('hipchat_from', '{{target}}');
set('hipchat_message', '_{{user}}_ deploying `{{branch}}` to *{{target}}*');
set('hipchat_url', 'https://api.hipchat.com/v1/rooms/message');
desc('Notifying Hipchat channel of deployment');
task('hipchat:notify', function () {
$params = [
'room_id' => get('hipchat_room_id'),
'from' => get('target'),
'message' => get('hipchat_message'),
'color' => get('hipchat_color'),
'auth_token' => get('hipchat_token'),
'notify' => 0,
'format' => 'json',
];
Httpie::get(get('hipchat_url'))
->query($params)
->send();
});