-1

i'm developing a web server in python that get payloads from a github webhook for specific events (push, new commits, pull requset...) how can i distenguise between thoese events throw gson? i've looked in the payload but fond nothing..:/ but in the other hand - i have a code that creates a handler for push event :

@webhook.hook() # Defines a handler for the 'push' event def on_push(data): print("Got push with: {0}".format(data))

so is there a built in "event detector" in the webhook library? found nothing online

EDIT : found this :"The type of activity is specified in the action property of the payload object. " BUT there is no keyword action in the payload i got and the type of event i triggered in github is a commit but all i got in payload says : 'modified': ['README.md'] 'message': 'Update README.md nothing straight forward

Ruba123
  • 1
  • 1
  • 2

1 Answers1

1

You should be able to parse the event type in the action property or in the X-GitHub-Event header value as noted in this documentation

If you're willing to use TypeScript instead, there's a great library for handling this parsing automatically called Probot.

Alternatively, if you want to stick to Python, there's this library which is similar: https://github.com/bradshjg/flask-githubapp

Aziz Sonawalla
  • 2,482
  • 1
  • 5
  • 6