frrbot
A GitHub bot for managing the FRRouting/frr repo.
Setup
- Install Python 3
- Clone repo &
cd frrbot - Install poetry
poetry install- Create and configure a GitHub App on GitHub, save the webhook secret, APP ID and private key
- Copy
config.yaml.exampletoconfig.yamland fill in the fields appropriately
Running
Notes:
-
Because this program invokes git from the shell, it needs to set the
user.nameanduser.emailoptions. Presently it does this globally so it will overwrite your configs for these. Running in Docker is recommended until this is fixed. -
When setting
gh_app_route, remember that this is relative to the uWSGI mountpoint. So for example if your uWSGI mountpoint is/frrbotand you setgp_app_routeto/gh, the full URL that frrbot will listen for GitHub webhooks on will be/frrbot/gh.
Option 1: flask run
- Set environment variable
FLASK_APP=frrbot.py - Fill out config file
- Execute
flask run - Configure your web server of choice to proxy your payload URL to
http://localhost:5000/and reload it
Option 2: WSGI
- Install uwsgi
- Fill out config file
- Use
./run.shto create and mount a WSGI endpoint on/frrbotand configure your web server to WSGI proxy your payload URL to it
Option 3: Docker
docker build --tag frrbot:latest .docker run -e GH_WEBHOOK_SECRET=<secret> GH_APP_ROUTE="/gh" GH_APP_ID=<ID> -e GH_APP_PKEY_PEM_PATH=<path> -e JOB_STORE_PATH=<path> --port 80:80 frrbot:latest- frrbot will be listening on
0.0.0.0:80/frrbot/gh
Notes for docker:
-
Environment variables are the preferred way to configure the container but it's also possible to mount
config.yamlinto the path/app/config.yamlif desired -
GH_WEBHOOK_SECRETshould be the webhook secret used to authenticate requests from GitHub -
GH_APP_IDshould be the ID of your GitHub App -
GP_APP_ROUTEshould be the URL you want to listen for webhooks on relative to the uWSGI mountpoint -
GH_APP_PKEY_PEM_PATHshould be the absolute path to the PEM format private key associated with your GitHub App; you should mount the key into the container at that path -
GH_GIST_USER_TOKENshould be a personal access token for a real user. This user will be used to host gists, since GitHub apps can't use gists. -
Since the job store should outlive the container, you should mount a volume where the job store should live from the host into the container before running and set
JOB_STORE_PATHappropriately. For example:docker run --mount type=bind,source=/opt/frrbot,target=/frrbot ... -e JOB_STORE_PATH=/frrbot/jobstore.sqlite frrbot:latest -
uWSGI options within the container can be modified by changing
uwsgi.iniin this repository root and rebuilding the container.