deployer/contrib/rollbar.php
Anton Medvedev 47a193f9af
Add docgen
2020-10-02 01:11:13 +03:00

56 lines
1.2 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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();