Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

A library for building GitHub apps.

Project description

Poebot

PyPI version Build Status Coverage Status Code style: black

Poebot is a Python library for building GitHub apps. Inspired by Probot and powered by Starlette.

Requirements

Python 3.6+

Installation

pip install poebot

You'll also need to install an ASGI server, such as uvicorn:

pip install uvicorn

Environment variables

Required

  • GITHUB_APP_IDENTIFIER
  • GITHUB_PRIVATE_KEY
  • GITHUB_WEBHOOK_SECRET

Optional

  • GITHUB_PRIVATE_KEY_BASE64 (default: False)
    Docker doesn't support multiline variables in .env file. So if you are using them together, you can set this variable to True and set GITHUB_PRIVATE_KEY to the base64 encoded version of your private key.
  • GITHUB_WEBHOOK_ROUTE (default: /)

Usage

Create a file main.py with the following code:

from poebot import Poebot

app = Poebot(debug=True)

@app.on_gh_event("issues", "opened")
async def add_bug_label(github, payload):
    repo = github.get_repo(payload["repository"]["full_name"])
    issue = repo.get_issue(payload["issue"]["number"])
    issue.add_to_labels("bug")

Then, in your terminal, run:

uvicorn main:app --host 0.0.0.0 --port 8000 --reload

The Poebot class provides:

  • a webhook that listens to GitHub events and verifies the incoming webhook signature;
  • a decorator on_gh_event for you to register GitHub event handlers.

The on_gh_event decorator has two parameters: the event type and action (can be None) to listen to.

The event handler receives two arguments:

  • an authenticated Github object (from PyGithub) to interact with GitHub API;
  • the event payload as a dictionary.

Release

  • [ ] Checkout to master branch.
  • [ ] Pull changes.
  • [ ] Checkout to a new branch release/x.x.x.
  • [ ] Bump version in setup.py.
  • [ ] Update CHANGELOG.md.
    • [ ] Add a blank line and ## [x.x.x] - YYYY-MM-DD bellow ## [Unreleased].
    • [ ] Update compare links at the bottom section.
  • [ ] Commit with message Release x.x.x and push.
  • [ ] Open and merge a PR with title Release x.x.x.
  • [ ] Delete branch release/x.x.x.
  • [ ] Checkout to master branch.
  • [ ] Pull changes.
  • [ ] Create a tag x.x.x.
  • [ ] Push the tag.
  • [ ] Create a release with title x.x.x.
    • [ ] Copy and paste the newest section from CHANGELOG.md to the release description.

Project details


Download files

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

Files for poebot, version 0.2.2
Filename, size File type Python version Upload date Hashes
Filename, size poebot-0.2.2-py3-none-any.whl (4.8 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size poebot-0.2.2.tar.gz (4.4 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page