Webhook receiver for Git deployments
Project description
Webhook receiver for Git deployments
This project started as a dirty & quick hack to perform some deployment actions triggered by a Git webhook.
I looked a little bit at other projects and didn't found any one that suited my needs, so I started this project... and then it grew a little bit and become something more versatile than the quick hack originally intended.
This project is aimed at DevOps or sysadmin that have git repositories, typically with a VIP-branch, and automatic deployment. You may want to have different branches for stage and production or set up push permissions differently to the different branches. This utility, when a webhook is received, will update the local Git repository and perform the commands in the settings.
Quickstart
- Create and activate a Virtual Environment:
virtualenv --python=/usr/bin/python3 /path/to/venv
source /path/to/venv/bin/activate
- Install the package:
pip install webhooks_git_automata
- Create a
settings.yaml
- Set up a service (e.g. a systemd service file) that does something along:
/path/to/venv/bin/wh-gitd /path/to/settings.yaml
Settings
Extra CLI features
To force both the pull and the execution of commands without a deployment, you can use
the built-in wh-git-trigger
command. Example usage:
wh-git-trigger /path/to/setings.yaml myrepoentry
This will force the git pull and execute the commands. Future versions of this tool will include more fine-grain control --e.g. avoid fetch, dry-run, display status information...
Implementation details
This project contains a minimal Flask server that answers the POST webhooks sent
by a Git server like GitLab, GitHub or Gogs. The server is started through the
Flask's app.run
method.
Not a lot of traffic is expected, but you may want to set up a reverse proxy in front of the Flask server, or add some fancier method like a WSGI or uWSGI or similar layer.
Typical git servers expect the webhook to send a quick reply (in general, HTTP
connections are intended to be short lived) so there is a worker/tasks approach. There
is a very simple implementation base on Threading
and a shared Queue
. More complex
implementations may be added in the future (pull requests welcome).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for webhooks_git_automata-0.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8e41739e9fa811f2721adcf2f61d3d0adb34437cd5d7769d6e6204d3aa2c4fb3 |
|
MD5 | 9445cbf55c66b1c08a8c04cb578adce4 |
|
BLAKE2b-256 | 669c6573748509a23c54b834c6ed838ebff4c3c9e78edd5bbdf59751733ef746 |
Hashes for webhooks_git_automata-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | df594d5fcbfc38af9278554fd41d8da021f4d106dd298ad9f5a7bdfdd83ffe1e |
|
MD5 | dedb4eabb806500756cfc4bc29f6b239 |
|
BLAKE2b-256 | 310da90a5f8bf8edb2a3e25842e1c13805d96603e93347dc5736ebcd03d83df9 |