A Python library to supercharge your GitHub organization with bots and webhooks.
Project description
About this project
FastGitHub provides a GitHub webhooks handler for FastAPI to automate your workflows.
FastGitHub also provides sets of automations (named recipes).
️️⚙️ Installation
Install the package from the PyPI registry.
pip install fastgithub
⚡ Usage
Example
from typing import Any
import uvicorn
from fastapi import FastAPI
from fastgithub import GithubWebhookHandler, SignatureVerificationSHA256, webhook_router
signature_verification = SignatureVerificationSHA256(secret="mysecret")
webhook_handler = GithubWebhookHandler(signature_verification)
@webhook_handler.listen("push")
def hello(data: dict[str, Any]):
print(f"Hello from: {data['repository']}")
app = FastAPI()
router = webhook_router(handler=webhook_handler, path="/postreceive")
app.include_router(router)
if __name__ == "__main__":
uvicorn.run(app)
You can also fill a list of functions for a specific event to the handler:
def hello(data: dict[str, Any]):
print(f"Hello from: {data['repository']}")
def bye(data: dict[str, Any]):
print(f"Goodbye from: {data['repository']}")
webhook_handler.listen("push", [hello, bye])
⛏️ Development
In order to install all development dependencies, run the following command:
uv sync
To ensure that you follow the development workflow, please setup the pre-commit hooks:
uv run pre-commit install
Acknowledgements
Initial ideas and designs are inspired by python-github-webhook and python-github-bot-api
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
File details
Details for the file fastgithub-0.0.3.tar.gz
.
File metadata
- Download URL: fastgithub-0.0.3.tar.gz
- Upload date:
- Size: 57.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b486a8db578d222cb8de63ea6aee75ce79bc0b9296055e592342538a9ac1348c |
|
MD5 | 1b9e4efb931baa244327277e64a48864 |
|
BLAKE2b-256 | d16502b10d0c804691691dbe433a502580562cb2d644496ee3b65c8cca63290a |
File details
Details for the file fastgithub-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: fastgithub-0.0.3-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9af8c0f5e82a35d9f9699abd7fb39ba4622710400e7931fbff0d8cf9003cb3ad |
|
MD5 | 632543b9b6eee3895e742c9116c023c5 |
|
BLAKE2b-256 | e54d2c9867da3c247c694320e0cfb013c05e38219fc1d63b580b4bfb6cb40597 |