Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

webhooks_git_automata-0.0.3.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

webhooks_git_automata-0.0.3-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file webhooks_git_automata-0.0.3.tar.gz.

File metadata

  • Download URL: webhooks_git_automata-0.0.3.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.1 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.5

File hashes

Hashes for webhooks_git_automata-0.0.3.tar.gz
Algorithm Hash digest
SHA256 818086b1fbaaa49f9ba292d63af2bfb3cbf9c1144d43e09522a07dab50961446
MD5 816cf314d994ff2157902b50332eede3
BLAKE2b-256 43061dce72638fe9d5ffb5638cb5cb552b57d6ea9fb76177b8c41eb6cac95849

See more details on using hashes here.

File details

Details for the file webhooks_git_automata-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: webhooks_git_automata-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.1 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.5

File hashes

Hashes for webhooks_git_automata-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b8fe5e6361a2811dd20e5a240f2b17148d81a63831d0c68b0d7c344a2fdbf3d5
MD5 2d3dcd40954a5535d561ef413969288b
BLAKE2b-256 2356364521fdc619b23661ec7c74152655c7a9debabd648ccd85e4985dd2760f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page