|
| 1 | +# Trigger your Netlify build hooks with ease |
| 2 | + |
| 3 | +[](https://packagist.org/packages/developmint/netlify-build-hook) |
| 4 | +[](LICENSE.md) |
| 5 | +[](https://travis-ci.org/Developmint/netlify-build-hook) |
| 6 | +[](https://scrutinizer-ci.com/g/developmint/netlify-build-hook) |
| 7 | +[](https://packagist.org/packages/developmint/netlify-build-hook) |
| 8 | + |
| 9 | +This package provides a lightweight class to trigger your [Netlify build hooks](https://www.netlify.com/docs/webhooks/#incoming-webhooks) |
| 10 | +properly. |
| 11 | + |
| 12 | + |
| 13 | +## Installation |
| 14 | + |
| 15 | +You can install the package via composer: |
| 16 | + |
| 17 | +``` bash |
| 18 | +composer require developmint/netlify-build-hook |
| 19 | +``` |
| 20 | + |
| 21 | +## Usage |
| 22 | + |
| 23 | +You must pass the following things to the constructor of `Developmint\NetlifyBuildHook\NetlifyBuildHook`. |
| 24 | + |
| 25 | +* A Guzzle client |
| 26 | +* The unique Identifier of you build hook (the last part of the build hook URL). |
| 27 | + |
| 28 | +The last two arguments are optional: |
| 29 | + |
| 30 | +* A custom title shown on Netlify |
| 31 | +* Another branch the deploy should use |
| 32 | + |
| 33 | +``` php |
| 34 | +$client = new \GuzzleHttp\Client(); |
| 35 | +$id = 'XXX' |
| 36 | +$hook = new \Developmint\NetlifyBuildHook\NetlifyBuildHook($client, $id); |
| 37 | + |
| 38 | +// Alternatively |
| 39 | + |
| 40 | +// With title |
| 41 | +$hook = new \Developmint\NetlifyBuildHook\NetlifyBuildHook($client, $id, 'My custom title'); |
| 42 | + |
| 43 | +// With branch |
| 44 | +$hook = new \Developmint\NetlifyBuildHook\NetlifyBuildHook($client, $id, null, 'other-branch'); |
| 45 | + |
| 46 | +// With everything |
| 47 | +$hook = new \Developmint\NetlifyBuildHook\NetlifyBuildHook($client, $id, 'My custom title', 'branch-name'); |
| 48 | +``` |
| 49 | + |
| 50 | +### Get stats for a package of your choice |
| 51 | + |
| 52 | +Trigger the hook with the corresponding `trigger`function of your class instance (from above). |
| 53 | +If a problem occurs, a `RequestException` will be thrown. |
| 54 | + |
| 55 | +``` php |
| 56 | +$hook->trigger(); |
| 57 | +``` |
| 58 | + |
| 59 | +## Changelog |
| 60 | + |
| 61 | +Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently. |
| 62 | + |
| 63 | +## Testing |
| 64 | + |
| 65 | +Testing wasn't entirely possible as mocking the hooks doesn't help anyone and test hooks are not available. |
| 66 | + |
| 67 | +``` bash |
| 68 | +$ composer test |
| 69 | +``` |
| 70 | + |
| 71 | +## Contributing |
| 72 | + |
| 73 | +Please see [CONTRIBUTING](CONTRIBUTING.md) for details. |
| 74 | + |
| 75 | +## Security |
| 76 | + |
| 77 | +If you discover any security related issues, please email [email protected] instead of using the issue tracker. |
| 78 | + |
| 79 | +## Credits |
| 80 | + |
| 81 | +- [Alexander Lichter](https://github.com/manniL) |
| 82 | +- [All Contributors](../../contributors) |
| 83 | + |
| 84 | + |
| 85 | +## License |
| 86 | + |
| 87 | +The MIT License (MIT). Please see [License File](LICENSE.md) for more information. |
0 commit comments