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.2.tar.gz
.
File metadata
- Download URL: fastgithub-0.0.2.tar.gz
- Upload date:
- Size: 57.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5aaf251a817c114df7d84801b86c22ce8794f75b5e655d236730df6fdb18b369 |
|
MD5 | 9369e231bc865a08508133176273875f |
|
BLAKE2b-256 | a5661d1e35de64aafb49bb0d695f058b38adbc71635063162a90a940b8c0a95f |
File details
Details for the file fastgithub-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: fastgithub-0.0.2-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 | 4eb5027451e5994a0b0095388667e24d13bdd0c8e435401430d8266813a7bf8b |
|
MD5 | 8351cfdd21e1b686745a512d8641b5f7 |
|
BLAKE2b-256 | 972e44fffc71e28c48ee5857e21bcc890b72e8b0429125930a737117a74e59a1 |