diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index b4ae1c4..0000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,55 +0,0 @@ -# Contributing - -Contributions are **welcome** and will be fully **credited**. - -Please read and understand the contribution guide before creating an issue or pull request. - -## Etiquette - -This project is open source, and as such, the maintainers give their free time to build and maintain the source code -held within. They make the code freely available in the hope that it will be of use to other developers. It would be -extremely unfair for them to suffer abuse or anger for their hard work. - -Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the -world that developers are civilized and selfless people. - -It's the duty of the maintainer to ensure that all submissions to the project are of sufficient -quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used. - -## Viability - -When requesting or submitting new features, first consider whether it might be useful to others. Open -source projects are used by many developers, who may have entirely different needs to your own. Think about -whether or not your feature is likely to be used by other users of the project. - -## Procedure - -Before filing an issue: - -- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident. -- Check to make sure your feature suggestion isn't already present within the project. -- Check the pull requests tab to ensure that the bug doesn't have a fix in progress. -- Check the pull requests tab to ensure that the feature isn't already in progress. - -Before submitting a pull request: - -- Check the codebase to ensure that your feature doesn't already exist. -- Check the pull requests to ensure that another person hasn't already submitted the feature or fix. - -## Requirements - -If the project maintainer has any additional requirements, you will find them listed here. - -- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](https://pear.php.net/package/PHP_CodeSniffer). - -- **Add tests!** - Your patch won't be accepted if it doesn't have tests. - -- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. - -- **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option. - -- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. - -- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting. - -**Happy coding**! diff --git a/README.md b/README.md index 26aa9bf..de0b4b5 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,111 @@ # Very short description of the package -[![Latest Version on Packagist](https://img.shields.io/packagist/v/ihah/gitlab-webhooks.svg?style=flat-square)](https://packagist.org/packages/ihah/gitlab-webhooks) -[![Build Status](https://img.shields.io/travis/ihah/gitlab-webhooks/master.svg?style=flat-square)](https://travis-ci.org/ihah/gitlab-webhooks) -[![Quality Score](https://img.shields.io/scrutinizer/g/ihah/gitlab-webhooks.svg?style=flat-square)](https://scrutinizer-ci.com/g/ihah/gitlab-webhooks) -[![Total Downloads](https://img.shields.io/packagist/dt/ihah/gitlab-webhooks.svg?style=flat-square)](https://packagist.org/packages/ihah/gitlab-webhooks) +[![Latest Version on Packagist](https://img.shields.io/packagist/v/ihah/webhook-notifier.svg?style=flat-square)](https://packagist.org/packages/ihah/webhook-notifier) +[![Total Downloads](https://img.shields.io/packagist/dt/ihah/webhook-notifier.svg?style=flat-square)](https://packagist.org/packages/ihah/webhook-notifier) -This is where your description should go. Try and limit it to a paragraph or two, and maybe throw in a mention of what PSRs you support to avoid any confusion with users and contributors. +Packages allows to receive GitLab/Github webhook payloads for Laravel application and send notifications to multiple Slack/Discord channels based on payload type. -## Installation +One configuration to control all process, easy to setup. + +# Packages status: ***under development*** + +## RoadMap: + +**GitLab:** +- [x] GitLab push event +- [ ] GitLab issue event +- [ ] GitLab merge request event + +**GitHub:** +- [ ] GitHub push event +- [ ] GitHub issue event +- [ ] GitHub merge request event + +**Slack:** +- [x] GitLab push notification to multiple channels +- [ ] GitLab issue notification to multiple channels +- [ ] GitLab merge notification to multiple channels +- [ ] GitHub push notification to multiple channels +- [ ] GitHub issue notification to multiple channels +- [ ] GitHub merge notification to multiple channels + +**Discord**: +- [ ] GitLab push notification to multiple channels +- [ ] GitLab issue notification to multiple channels +- [ ] GitLab merge notification to multiple channels +- [ ] GitHub push notification to multiple channels +- [ ] GitHub issue notification to multiple channels +- [ ] GitHub merge notification to multiple channels + +**Road Map:** +- [ ] Implement events and listeners +- [ ] Send notifications using queues + + +# Installation You can install the package via composer: ```bash -composer require ihah/gitlab-webhooks +composer require ihah/webhook-notifier +``` + +**Publish config file** + +```bash +php artisan vendor:publish --provider="Ihah\WebhookNotifier\WebhookNotifierServiceProvider" --tag=config ``` -## Usage +**Add webhook notifier routes.** + +```php +// Recommended routes add to routes/api.php +WebhookNotifier::routes(); + +// It is possible to define multi middlewares for all routes +WebhookNotifier::routes(['middlewares' => ['api']]); +``` + + +# Usage + +## Gitlab + Slack + +1. Define `GITLAB_TOKEN` in .env file. +* `GITLAB_TOKEN` is used to check if request came from GitLab. +* `GITLAB_TOKEN` should be set as webhook **secret token** in GitLab [More information about GitLab webhooks](https://docs.gitlab.com/ee/user/project/integrations/webhooks.html). + +2. Config `../config/webhook-notifier.php` file +* Slack incomming webook urls should be always defined in .env file because they contain secret to your channel and can be blocked if they are leaked. [More information about Slack Incoming Webhooks](https://api.slack.com/messaging/webhooks) +* `all` array - send all supported notifications to defined channels +* `push` array - send all push notifications to defined channels + ``` php -// Usage description here +// .../config/webhook-notifier.php + +'gitlab_token' => env('GITLAB_TOKEN'), + 'slack' => [ + 'channels' => [ + 'all' => [ + [ + 'name' => 'ricks-gitlab-channel', + 'url' => env('RICKS_SLACK_CHANNEL_URL') + ] + ], + + 'push' => [ + [ + 'name' => 'toms-gitlab-channel', + 'url' => env('TOMS_SLACK_CHANNEL_URL') + ], + [ + 'name' => 'jams-gitlab-channel', + 'url' => env('JAMS_SLACK_CHANNEL_URL') + ], + ] + ], + ], ``` ### Testing @@ -31,10 +118,6 @@ composer test Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently. -## Contributing - -Please see [CONTRIBUTING](CONTRIBUTING.md) for details. - ### Security If you discover any security related issues, please email ernestasdev@gmail.com instead of using the issue tracker. @@ -46,8 +129,4 @@ If you discover any security related issues, please email ernestasdev@gmail.com ## License -The MIT License (MIT). Please see [License File](LICENSE.md) for more information. - -## Laravel Package Boilerplate - -This package was generated using the [Laravel Package Boilerplate](https://laravelpackageboilerplate.com). \ No newline at end of file +The MIT License (MIT). Please see [License File](LICENSE.md) for more information. \ No newline at end of file diff --git a/composer.json b/composer.json index 2794a7c..18f91ca 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "ihah/webhook-notifier", - "description": "Allows to receive Gitlab webhooks for Laravel application and send notifications to the Slack channels", + "description": "Allows to receive Gitlab/Github webhooks for Laravel application and send notifications to the Slack/Discord channels", "keywords": [ "ihah", "webhook-notifier"