forked from deployphp/deployer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollbar.php
55 lines (42 loc) · 1.24 KB
/
rollbar.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
54
55
<?php
/*
## Installing
Add to your _deploy.php_
```php
require 'contrib/rollbar.php';
```
## Configuration
- `rollbar_token` – access token to rollbar api
- `rollbar_comment` – comment about deploy, default to
```php
set('rollbar_comment', '_{{user}}_ deploying `{{branch}}` to *{{target}}*');
```
- `rollbar_username` – rollbar user name
## Usage
Since you should only notify Rollbar channel of a successful deployment, the `rollbar:notify` task should be executed right at the end.
```php
after('deploy', 'rollbar:notify');
```
*/
namespace Deployer;
use Deployer\Utility\Httpie;
set('rollbar_comment', '_{{user}}_ deploying `{{branch}}` to *{{target}}*');
desc('Notifying Rollbar of deployment');
task('rollbar:notify', function () {
if (!get('rollbar_token', false)) {
return;
}
$params = [
'access_token' => get('rollbar_token'),
'environment' => get('target'),
'revision' => runLocally('git log -n 1 --format="%h"'),
'local_username' => get('user'),
'rollbar_username' => get('rollbar_username'),
'comment' => get('rollbar_comment'),
];
Httpie::post('https://api.rollbar.com/api/1/deploy/')
->form($params)
->send();
})
->once()
->shallow();