Skip to content

jbuisine/flask-webhook-deploy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Webhooks tasks deployement using Flask

Description

This project proposes the use of a Python flask server to validate the action of a github webhook. The secret key given at the creation of the webhook is verified and allows the execution of the particular system command. For example, a bash script allowing a specific deployment.

You can create a webhook for your project from: https://github.com/${username}/${project}/settings/hooks.

Installation

Install the Python requirements:

pip install -r requirements.txt

Then create a configuration file config.json adapted to your needs by replacing the content of the proposed config.example.json file:

{
    "flask_secret": "your_flask_app_secret",
    "webhook_secret": "your_webhook_secret",
    "command": "echo \"Webhook has been reached\"" 
}

Note: you can generate your own flask secret key. A secret key that will be used for securely signing the session cookie.

Run the server

Finnaly, you can run your webhook management server:

gunicorn --bind 0.0.0.0:5000 wsgi:app

Note: from the webhook configuration, run it again if necessary (without submitting a particular commit) to check that it works.

License

MIT