Skip to main content

A Python library to supercharge your GitHub organization with bots and webhooks.

Project description

FastGitHub

CI/CD CI Pipeline Release Interrogate Codecov
Meta Ruff Pre-commit License
Package PyPI - Python version PyPI - Version

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
from fastapi import FastAPI
import uvicorn
from fastgithub.endpoint.webhook_router import webhook_router
from fastgithub.recipes.github import autocreate_pull_request
from fastgithub.webhook import GithubWebhookHandler

webhook_handler = GithubWebhookHandler(
    token="your-secret-token"
)  # by default os.environ["GITHUB_TOKEN"]


@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


Download files

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

Source Distribution

fastgithub-0.0.1.tar.gz (59.4 kB view details)

Uploaded Source

Built Distribution

fastgithub-0.0.1-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file fastgithub-0.0.1.tar.gz.

File metadata

  • Download URL: fastgithub-0.0.1.tar.gz
  • Upload date:
  • Size: 59.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.4

File hashes

Hashes for fastgithub-0.0.1.tar.gz
Algorithm Hash digest
SHA256 7cff588c74d950f17f7ce6c78701ce05ab08b7e27889cfcb2c20c73cfddfe091
MD5 3f6236bf6d43ce8838b7f92e86bbee05
BLAKE2b-256 b6fc4457f46f982636dd2789a93457c8d7db393413bdb6f04504a0b68e06e16c

See more details on using hashes here.

File details

Details for the file fastgithub-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for fastgithub-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b91d947513afec336a9536b68ff5168bab7b5e7af8893693517493658d89e34d
MD5 3dadaf35010e390fc04001e757109d55
BLAKE2b-256 1cc17f618eaaf4690aec28ea505c990c8f0fc408fc0ff3482147bbe803fec3e5

See more details on using hashes here.

Supported by

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