All Projects → FlyingKatsu-Discord-Bots → Discord-GitLab-Webhook

FlyingKatsu-Discord-Bots / Discord-GitLab-Webhook

Licence: MIT License
A Discord bot for using webhooks with GitLab (and extendable for other custom webhooks not yet built into Discord).

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Discord-GitLab-Webhook

Hwamei
企业微信webhook,企业微信群机器人webhook,支持Github、Gitlab、Sentry等Webhook
Stars: ✭ 142 (+305.71%)
Mutual labels:  gitlab, webhook
Git Auto Deploy
Deploy your GitHub, GitLab or Bitbucket projects automatically on Git push events or web hooks
Stars: ✭ 251 (+617.14%)
Mutual labels:  gitlab, webhook
Packages
Enhances Composer Satis with webhook integrations to GitHub and GitLab
Stars: ✭ 157 (+348.57%)
Mutual labels:  gitlab, webhook
Git Deploy
Php Script for Auto-Pull in server (Using WebHook from GitLab, GitHub and Bitbucket)
Stars: ✭ 495 (+1314.29%)
Mutual labels:  gitlab, webhook
YappyGitHub
A github monitor bot for Discord
Stars: ✭ 64 (+82.86%)
Mutual labels:  webhook, discord-bot
Git Webhook
使用 Python Flask + SQLAchemy + Celery + Redis + React 开发的用于迅速搭建并使用 WebHook 进行自动化部署和运维,支持 Github / GitLab / Gogs / GitOsc。
Stars: ✭ 1,439 (+4011.43%)
Mutual labels:  gitlab, webhook
Webhookit
Simple git webhook cli tool for automation tasks, bind git webhook to action.
Stars: ✭ 177 (+405.71%)
Mutual labels:  gitlab, webhook
Go Git Webhook
Golang 实现的自动化部署和运维工具,支持:Github / GitLab / GitOsc。
Stars: ✭ 173 (+394.29%)
Mutual labels:  gitlab, webhook
froggit-go
Froggit-Go is a universal Go library, allowing to perform actions on VCS providers.
Stars: ✭ 19 (-45.71%)
Mutual labels:  gitlab, webhook
epf-transmitter
astrizhachuk.github.io/epf-transmitter/
Stars: ✭ 32 (-8.57%)
Mutual labels:  gitlab, webhook
gitlab-ci-discord-webhook
⛓ Here's your serverless solution for sending build status from GitLab CI to Discord as webhooks.
Stars: ✭ 32 (-8.57%)
Mutual labels:  gitlab, webhook
rocketchat-gitlab-hook
Add GitLab notifications via a new WebHook in Rocket.Chat
Stars: ✭ 80 (+128.57%)
Mutual labels:  gitlab, webhook
Generic Webhook Trigger Plugin
Can receive any HTTP request, extract any values from JSON or XML and trigger a job with those values available as variables. Works with GitHub, GitLab, Bitbucket, Jira and many more.
Stars: ✭ 287 (+720%)
Mutual labels:  gitlab, webhook
Gitwebhookproxy
A proxy to let webhooks reach running services behind a firewall – [✩Star] if you're using it!
Stars: ✭ 123 (+251.43%)
Mutual labels:  gitlab, webhook
Skyhook
Parses webhooks and forwards them in the proper format to Discord.
Stars: ✭ 263 (+651.43%)
Mutual labels:  gitlab, webhook
YappyGitLab
A GitLab monitor bot for Discord
Stars: ✭ 51 (+45.71%)
Mutual labels:  gitlab, webhook
pm2-githook
receive webhook from github/gitlab and ask pm2 to reload the application for you
Stars: ✭ 39 (+11.43%)
Mutual labels:  gitlab, webhook
plugin-gitlab-webhook
[NOT MAINTAINED] Gitlab Webhook Plugin for Kanboard
Stars: ✭ 31 (-11.43%)
Mutual labels:  gitlab, webhook
corde
🤖 A simple e2e library for testing Discord Bots 🚀
Stars: ✭ 60 (+71.43%)
Mutual labels:  discord-bot
Belphegor
A personal discord bot written in python.
Stars: ✭ 13 (-62.86%)
Mutual labels:  discord-bot

Discord Server

Discord-GitLab Webhook Bot

A Discord bot for using webhooks with GitLab (and extendable for other custom webhooks not yet built into Discord).

Preview of embed messages sent via webhook

GitLab Event Support

  • Push Events
  • Issue Events
  • Comment Events
    • Commits
    • Merge Requests
    • Issues
    • Code Snippets
  • Merge Request Events
  • Wiki Page Events
  • Tag Events (Not yet)
  • Pipeline Events (Not yet)
  • Build Events (Not yet)

Installation

  1. Clone this repo
  2. Install NodeJS
  3. Navigate to the cloned repo
  4. Initialize the NodeJS app with npm install
  5. All of the dependencies listed in package.json should automatically be installed to node_modules/
  6. Install pm2 using npm install pm2@latest -g
  7. Update pm2

Command Line Summary

# make a parent directory for containing the repo, if desired
mkdir my_bots
# navigate to your desired directory
cd my_bots
# either clone via HTTPS
git clone https://github.com/Warped2713/Discord-GitLab-Webhook.git
# ... or clone via SSH
git clone [email protected]:Warped2713/Discord-GitLab-Webhook.git
# navigate to the cloned repo
cd discord-gitlab-webhook
# install the app via NodeJS, using package.json
npm install
# install pm2
npm install pm2@latest -g
# update pm2
pm2 update

Dependencies

The package.json file includes the following dependencies:

  • discordJS for integrating with Discord
    • erlpack for much faster websockets
  • pm2 for monitoring and maintaining uptime

Configuration

  1. Create your Discord Bot at https://discordapp.com/developers/applications/me Keep this tab open so you can easily access Client ID and Client Secret
  2. Make your Discord app a Bot User by clicking the "Create Bot User" button in your app page settings.
  3. Calculated the desired permissions for your bot at https://discordapi.com/permissions.html (or use the default 536964096)
  4. Authorize your Discord Bot for your server using https://discordapp.com/oauth2/authorize?client_id={YOUR_CLIENT_ID}&scope=bot&permissions={YOUR_CALCULATED_PERMISSIONS} NOTE: if you get "Unexpected Error" then you probably forgot to turn your Discord App into a Bot User in Step 2.
  5. In your local bot repo, copy the dev/require/config-dummy.json to dev/require/config.json and fill in the data according to the instructions
  6. In your local GitLab server, set up a new webhook using your chosen URL (server.address:server.port), and the DGW_WEBHOOK_TOKEN (or webhook.token) specified in your config file.
  7. Run the bot using pm2 start server.js --name dgw-bot or simply node server.js if you don't want to use pm2
  8. Test the webhook by clicking the 'Test' button in GitLab's integrations page

Using Environment Variables for Secret Tokens (optional)

Instead of keeping your secret tokens in a file, you can choose to set up environment variables and export them for use with the bot script

echo $DGW_BOT_TOKEN
export DGW_BOT_TOKEN=MySecretDiscordBotToken
echo $DGW_BOT_TOKEN

echo $DGW_WEBHOOK_TOKEN
export DGW_WEBHOOK_TOKEN=MySecretWebhookToken
echo $DGW_WEBHOOK_TOKEN

Sending Test HTTP Requests

Use GitLab's Tests

In your GitLab instance (either on the web or on your own server), go to Settings > Integrations and find (or create) your webhook. Use the drop-down menu next to your webhook's details to test different event types.

Note that some events will require additional setup on your GitLab instance, such as a .gitlab-ci.yml script for your Pipeline and Job events, and an initial wiki page for your wiki events.

Run the client script

To test HTTP Requests, you can modify and use the client script, ex-client.js:

pm2 start server.js
node ex-client.js

Run cURL

If you want to test HTTP Requests without a GitLab setup, you can use cURL to send fake requests with sample data:

cat sample/push.json | curl -i -v -X POST localhost:9000 -H "Content-Type: application/json" -H 'X-Gitlab-Token: TOKEN' -H 'X-Gitlab-Event: Push Hook' --data-binary "@-"
  • sample/push.json refers to the sample data in the local repo
  • localhost:9000 corresponds to the server.address and server.port in your config file
  • TOKEN is your webhook.token or environment variable DGW_WEBHOOK_TOKEN that you get from Discord when you create/edit a webhook
  • Push Hook is the event that corresponds to the type of data you send, in this case, a GitLab Push Hook

Bot Commands

Debug Mode

>debug or >debug false

Tell the bot whether or not to enter Debug mode. When in Debug mode, any incoming GitLab HTTP requests received by the bot's HTTP server will be printed to your #debug-channel in your Discord server. This can be helpful for figuring out why the data might not be properly displayed by the webhook's embed messages, but can also spam your channel if the data is very long. Only a master user is allowed to use this command.

Clear (Bulk Delete) Messages

>clear NUM #CHANNEL

Deletes the specified number of messages from the mentioned channel. Only messages from the most recent two weeks will be deleted, as specified by the DiscordAPI. Both the bot and the user must have permission to "Manage Messages" for the specified channel. Also replies to the user to acknowledge receiving the command.

  • NUM must be a number greater than or equal to 2 and less than 100
  • #CHANNEL must be a valid text channel in your guild/server

Disconnect Bot

>disconnect TIME

Tell the bot to stay logged out for TIME milliseconds (default is 5 seconds, max is 1 hour). The bot should automatically log itself back in after TIME is up. Only a master user is allowed to use this command. No commands will be processed during the timeout, but the server will still attempt to listen for incoming HTTP requests (which the bot will try to process when it logs back in).

Embed Sample Data

>embed TYPE

Sends an embedded message via webhook, using data read from the specified sample file. Also replies to the user to acknowledge receiving the command.

TYPE must be one of the properties of the SAMPLE object:

Ping-Pong

>ping

Sends "pong" to the same channel in which the command was called.

Test Embed

>test

Sends an embedded message via webhook, using some placeholder RichEmbed data with Markdown formatting. Also replies to the user to acknowledge receiving the command.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].