A simple python bot that serves to send some notifications about GitHub events to Slack.

Overview

github alerts slack bot 🤖

What is it? 🔍

This is a simple bot that serves to send some notifications about GitHub events to Slack channels.

These are the features currently developed:

  • notification to inform Pull Requests with conflicts

Others features may be developed in the future.


How it works 🧑‍🏭

  • GitHub webhook send a request to bot to selected event (Pull Request has been opened, per example)
  • It handle the request
    • it check if the request comes from the correct GitHub webhook to avoid fraud
    • it don't send repeated notification with same data on the same day
  • Whether yes, the Slack webhook is called to create a message in on channel with the information (a Pull Request is open)

Configuration ⚙️

Create a access token of GitHub

Navigate to Settings > Developer Settings > Personal access tokens > Generate new token

The permission repo is only need to access necessary datas of yours repositories: image

Save the access token after creating it.

Create a workflow in Slack

The workflow is the point used to send the notifications and here there are a tutorial to create one.

The only var required in the text is prs_list.

You can customize the message of your workflow as you wish:

example of workflow

After create, save the workflow webhook.

Deploy the bot

First, create your fork of this project to can perform the deploy.

The our bot is configured to deploy in Heroku. Heroku is a cloud platform to deploy your simple projects, they have a free plan that will be enough for us. You can also choose another cloud platform to do this.

Create a new app > Select the deploy on GitHub > Choose your fork of this project

Greate! If everything is ok, you can see this message:

success deploy

Install Redis

Redis is used to check if one message is send in the past day with the same pull requests.

In the dashboard of your project in Heroku, go to Resources > Find more add-ons

Select Redis Enterprise Cloud. It will probably ask you to set up the credit card on your account, but don't worry, the free plan is enough to our bot. After set up your credit card, select the free plan and the project of bot to install the Redis.

It is listed in your add-ons if everything is ok:

redis add-on

Access the add-on and complete the Redis url with the datas: http://rediscloud:password@hostname:port

Like this: http://rediscloud:cofe6kWpNnsdlfkçlç[email protected]:1234

This will be used to connect our bot with the Redis.

Create GitHub webhook

Your repository to track > Settings > Webhooks > add webhook

In the Payload URL, past the URL of your Heroku project and the endpoint check_conflicts. Like this: https://my-heroku-app.herokuapp.com/check_conflicts

The Content type is application/json.

I recommend using a UUID in the Secret. This will ensure the security of the requests. Save this secret to use in virtual environments of the project

In the events, select Let me select individual events. and select Pull requests in the list of events.

Now just save.

Setting envs

Finally, the last step is set the virtual environments in the Heroku project.

Heroku project > Settings > Reveal Config vars.

Now set this envs:

  • SECRET_ACCESS: secret used in GitHub webhook
  • ACCESS_TOKEN: your access token of GitHub
  • PROJECT_TO_TRACK: project of the GitHub webhook. Example: jackson541/github-alerts-slack-bot
  • BRANCH_TO_TRACK: the branch of the project that you want to track. Example: master
  • SLACK_WEBHOOK_LINK: the URL of the workflow created in Slack
  • REDIS_URL: the URL created with the datas of Redis. example: http://rediscloud:cofe6kWpNnsdlfkçlç[email protected]:1234

You can stop and have your coffee, everything is set up!


Contribute

Contribute is always well received! Feel free to open Pull Requests or Issues. 😄

You might also like...
A discord bot providing notifications of player activity on a minecraft server.

tos-alert A discord bot providing notifications of player activity on a minecraft server. Setup By default the app does not launch and will crash with

Simple Discord bot which logs several events in your server

logging-bot Simple Discord bot which logs several events in your server, including: Message Edits Message Deletes Role Adds Role Removes Member joins

🤖 Automated follow/unfollow bot for GitHub. Uses GitHub API. Written in python.

GitHub Follow Bot Table of Contents Disclaimer How to Use Install requirements Authenticate Get a GitHub Personal Access Token Add your GitHub usernam

A slack bot that notifies you when a restaurant is available for orders
A slack bot that notifies you when a restaurant is available for orders

Slack Wolt Notifier A Slack bot that notifies you when a Wolt restaurant or venue is available for orders. How does it work? Slack supports bots that

A self hosted slack bot to conduct standups & generate reports.
A self hosted slack bot to conduct standups & generate reports.

StandupMonkey A self hosted slack bot to conduct standups & generate reports. Report Bug · Request Feature Installation Install already hosted bot (Us

Slack bot for monitoring your Metaflow flows!
Slack bot for monitoring your Metaflow flows!

Metaflowbot - Slack Bot for your Metaflow flows! Metaflowbot makes it fun and easy to monitor your Metaflow runs, past and present. Imagine starting a

Bender: A Markov Babbler Slack Bot

See the Digital Ocean tutorial for instructions on how to get the basic bot structure in place. Once you have that, set the gunicorn command to run as

Slack bot to automatically delete yubisneeze / accidental yubikey presses
Slack bot to automatically delete yubisneeze / accidental yubikey presses

YubiSnooze Slack bot to automatically delete yubisneeze / accidental yubikey presses. It will search using the regex "[cbdefghijklnrtuv]{44}" and if t

A Slack bot for playing Texas Hold 'Em where the currency is various workout tasks e.g. pushups

A Slack app/bot for playing Texas Hold 'Em where the currency is various workout tasks e.g. pushups. The intent is to make the workday more fun & active for remote teams.

Owner
Jackson Alves
Formação de Técnico em informática pelo IFRN e atualmente cursando Ciência e Tecnologia na UFRN.
Jackson Alves
Receive GitHub webhook events and send to Telegram chats with AIOHTTP through Telegram Bot API

GitHub Webhook to Telegram Receive GitHub webhook events and send to Telegram chats with AIOHTTP through Telegram Bot API What this project do is very

Dash Eclipse 33 Jan 3, 2023
A self-bot for discord, written in Python, which will send you notifications to your desktop if it detects an intruder on your discord server

A self-bot for discord, written in Python, which will send you notifications to your desktop if it detects an intruder on your discord server

LevPrav 1 Jan 11, 2022
A Python wrapper around the Pushbullet API to send different types of push notifications to your phone or/and computer.

pushbullet-python A Python wrapper around the Pushbullet API to send different types of push notifications to your phone or/and computer. Installation

Janu Lingeswaran 1 Jan 14, 2022
A python script that can send notifications to your phone via SMS text

Discord SMS Notification A python script that help you send text message to your phone one of your desire discord channel have a new message. The proj

null 2 Apr 25, 2022
A management system designed for the employees of MIRAS (Art Gallery). It is used to sell/cancel tickets, book/cancel events and keeps track of all upcoming events.

Art-Galleria-Management-System Its a management system designed for the employees of MIRAS (Art Gallery). Backend : Python Frontend : Django Database

Areesha Tahir 8 Nov 30, 2022
This automation protect against subdomain takeover on AWS env which also send alerts on slack.

AWS_Subdomain_Takeover_Detector Purpose The purpose of this automation is to detect misconfigured Route53 entries which are vulnerable to subdomain ta

Puneet Kumar Maurya 8 May 18, 2022
Slack->DynamDB->Some applications

slack-event-subscriptions About The Project Do you want to get simple attendance checks? If you are using Slack, participants can just react on a spec

UpstageAI 26 May 28, 2022
An implementation of webhook used to notify GitHub repository events to DingTalk.

GitHub to DingTask An implementation of webhook used to notify GitHub repository events to DingTalk.

Prodesire 5 Oct 2, 2022
Automatically send commands to send Twitch followers to any Twitch account.

Automatically send commands to send Twitch followers to any Twitch account. You just need to be in a Twitch follow bot Discord server!

Thomas Keig 6 Nov 27, 2022
This Discord bot is to give timely notifications to Students in the Lakehead CS 2021 Guild

Discord-Bot Goal of Project The purpose of this Discord bot is to give timely notifications to Students in the Lakehead CS 2021 Guild. How can I contr

null 8 Jan 30, 2022