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:[email protected]: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. 😄

Owner
Jackson Alves
Formação de Técnico em informática pelo IFRN e atualmente cursando Ciência e Tecnologia na UFRN.
Jackson Alves
A simple telegram bot to forward files from one channel to other.

Forward_2.0 Bot to forward messages from one channel to other without admin permission in source channel. Can be used for both private and Public chan

SUBIN 56 Dec 29, 2022
Embed the Duktape JS interpreter in Python

Introduction Pyduktape is a python wrapper around Duktape, an embeddable Javascript interpreter. On top of the interpreter wrapper, pyduktape offers e

Stefano 78 Dec 15, 2022
Set of classes and tools to communicate with a Noso wallet using NosoP

NosoPy Set of classes and tools to communicate with a Noso wallet using NosoP(Noso Protocol). The data that can be retrieved consist of: Node informat

Noso Project 1 Jan 10, 2022
My attempt at weaponizing Discord.

MayorbotC2 This is my Discord C2 bot. There are many like it, but this one is mine. MayorbotC2 is a project I absolutely forgot about until I was pilf

Joe Helle 19 May 16, 2022
Manage Proxmox KVM Virtual Machines via Slack bot.

proxmox-slack-bot Create KVM Virtual Machines on Proxmox, the easy way. Not much works works here yet... Setup dev environment Setup fully editable st

Plenus Pyramis 3 Mar 20, 2022
HTTP API for TON (The Open Network)

HTTP API for The Open Network Since TON nodes uses its own ADNL binary transport protocol, a intermediate service is needed for an HTTP connection. TO

66 Dec 28, 2022
IdeasBot - Funny telegram bot to generate ideas for a project

Repository of PIdeas_bot About Funny telegram bot for generating projects ideas.

Just Koala 5 Oct 16, 2022
A simple bot to upload file to various cloud servers.

Cloudsy Bot A simple bot to upload file to various cloud servers. Variables API_HASH Your API Hash from my.telegram.org API_ID Your API ID from my.tel

Flying Santas 8 Oct 31, 2022
BingBot - A bot that will automate searches on bing

bingBot A bot that will automate searches on bing. To install this just download

Lukas 2 Jul 28, 2022
A collection of discord tools I've made.

Discord A collection of discord tools i've made. What's in here? Basically every discord related project i've worked on can be found here, i'll try an

?? ?? ?? 6 Nov 13, 2021
Disqus API bindings for Python

disqus-python Let's start with installing the API: pip install disqus-python Use the API by instantiating it, and then calling the method through dott

DISQUS 163 Oct 14, 2022
Um simples bot escrito em Python usando a lib pyTelegramBotAPI

Telegram Bot Python Um simples bot escrito em Python usando a lib pyTelegramBotAPI Instalação Windows: Download do Python 3 Aqui Download do ZIP do Có

Sr_Yuu 1 May 07, 2022
Github integration with Telegram

The Telegram bot myGit is your GiHub assistant. In your conversations with your team, you can simply insert the information about the projects you are working at.

Alexandru Buzescu 2 Jan 06, 2022
Python wrapper for Xeno-canto API 2.0. Enables downloading bird data with one command line

Python wrapper for Xeno-canto API 2.0. Enables downloading bird data with one command line. Supports multithreading

_zza 9 Dec 10, 2022
PS3API - PS3 API for TMAPI and CCAPI in python.

PS3API PS3 API for TMAPI and CCAPI in python. Examples Connecting and Attaching from ps3api import PS3API PS3 = PS3API(PS3API.API_TMAPI) if PS3.Conn

Adam 9 Sep 01, 2022
google-resumable-media Apache-2google-resumable-media (🥉28 · ⭐ 27) - Utilities for Google Media Downloads and Resumable.. Apache-2

google-resumable-media Utilities for Google Media Downloads and Resumable Uploads See the docs for examples and usage. Experimental asyncio Support Wh

Google APIs 36 Nov 22, 2022
Python functions for opentargets.org API

What is opy_Targets? Opentargets.org uses GraphQL API to explore it's content via coding. This ensemble of functions aim is to make it easy to use the

1 Jan 10, 2022
Home Assistant Hilo Integration via HACS

BETA This is a beta release. There will be some bugs, issues, etc. Please bear with us and open issues in the repo. Hilo Hilo integration for Home Ass

66 Dec 23, 2022
Tinkoff social pulse api wrapper

Tinkoff social pulse api wrapper

Semenov Artur 9 Dec 20, 2022
Easy to use Google Pub/Sub

Relé makes integration with Google PubSub straightforward and easy. Motivation and Features The Publish-Subscribe pattern and specifically the Google

Mercadona 188 Jan 06, 2023