deployer/contrib/rollbar.php

48 lines
1.2 KiB
PHP
Raw Normal View History

2020-04-25 23:00:08 +03:00
<?php
2020-10-02 00:11:13 +02:00
/*
## 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
2020-04-25 23:00:08 +03:00
2020-10-02 00:11:13 +02:00
## 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');
```
*/
2020-04-25 23:00:08 +03:00
namespace Deployer;
use Deployer\Utility\Httpie;
set('rollbar_comment', '_{{user}}_ deploying `{{branch}}` to *{{target}}*');
2021-11-08 22:59:39 +01:00
desc('Notifies Rollbar of deployment');
2020-04-25 23:00:08 +03:00
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/')
2021-11-07 10:49:16 +01:00
->formBody($params)
2020-04-25 23:00:08 +03:00
->send();
})
2021-11-21 10:57:25 +01:00
->once();