Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added artisan:bugsnag:deploy task #3557

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
41 changes: 38 additions & 3 deletions contrib/bugsnag.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,39 @@

## Configuration

- *bugsnag_api_key* – the API Key associated with the project. Informs Bugsnag which project has been deployed. This is the only required field.
- *bugsnag_api_key* – the API Key associated with the project. Informs BugSnag which project has been deployed. This is the only required field.
- *bugsnag_provider* – the name of your source control provider. Required when repository is supplied and only for on-premise services.
- *bugsnag_app_version* – the app version of the code you are currently deploying. Only set this if you tag your releases with semantic version numbers and deploy infrequently. (Optional.)

If you use Laravel, follow the official [BugSnag integration guide](https://docs.bugsnag.com/platforms/php/laravel).

## Usage

Since you should only notify Bugsnag of a successful deployment, the `bugsnag:notify` task should be executed right at the end.
Since you should only notify BugSnag of a successful deployment, the `bugsnag:notify` task should be executed right at the end.

```php
after('deploy', 'bugsnag:notify');
```

If you want to use the Laravel Artisan command, call the `artisan:bugsnag:deploy` task to notify BugSnag of new releases.
Please note that you have to manually register the BugSnag `DeployCommand` command in your `app/Console/Kernel.php` file.

```php
after('deploy', 'artisan:bugsnag:deploy');
```

*/
namespace Deployer;

use Deployer\Utility\Httpie;

desc('Notifies Bugsnag of deployment');
/*
* We will extend the Laravel recipe to simply add BugSnag
* provided Artisan command.
*/
require_once __DIR__ . '/../recipe/laravel.php';

desc('Notifies BugSnag of deployment');
task('bugsnag:notify', function () {
$data = [
'apiKey' => get('bugsnag_api_key'),
Expand All @@ -35,3 +51,22 @@
->jsonBody($data)
->send();
});

desc('Notifies BugSnag of releases using the Laravel Artisan console');
task('artisan:bugsnag:deploy', function () {
$data = [
'repository' => get('repository'),
'revision' => get('release_revision'),
'provider' => get('bugsnag_provider'),
'builder' => get('user')
];

$options = '';
foreach ($data as $key => $value) {
if ($value !== null) {
$options .= " --$key=\"$value\"";
}
}

artisan("bugsnag:deploy $options")();
});