ihah/webhook-notifier

Allows to receive Gitlab/Github webhooks for Laravel application and send notifications to the Slack/Discord channels

dev-master 2020-11-15 17:35 UTC

This package is auto-updated.

Last update: 2024-05-20 20:46:32 UTC


README

Latest Version on Packagist Total Downloads

Webhook-notifier package allows to receive GitLab/Github webhook payloads for Laravel application and send notifications to multiple Slack/Discord channels based on payload type.

One configuration to control all process, easy to setup.

Packages status: under development

Installation

You can install the package via composer:

composer require ihah/webhook-notifier

Publish config file

php artisan vendor:publish --provider="Ihah\WebhookNotifier\WebhookNotifierServiceProvider" --tag=config

Usage

Gitlab + Slack

By default gitlab notification webhook for slack is:

domain.com/gitlab/notify/slack
  1. Define GITLAB_TOKEN in .env file.
  1. 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
  • all array - send all supported notifications to defined channels
  • push array - send all push notifications to defined channels
// .../config/webhook-notifier.php

'gitlab_token' => env('GITLAB_TOKEN'),
    'slack' => [
        'prefix' => 'gitlab/notify/',
        'middleware'=> [],
        '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

composer test

RoadMap:

GitLab:

  • GitLab push event
  • GitLab issue event
  • GitLab merge request event

GitHub:

  • GitHub push event
  • GitHub issue event
  • GitHub merge request event

Slack:

  • 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

Other:

  • Support events and listeners
  • Send notifications using queues

Changelog

Please see CHANGELOG for more information what has changed recently.

Security

If you discover any security related issues, please email ernestasdev@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.