0

I'm trying to setup GitHub webhook to trigger some backend activities only when the GitHub event is either a commit or a merge to the master branch.

{
  "zen": "Practicality beats purity.",
  "hook_id": 226668888,
  "hook": {
    "type": "Repository",
    "id": 226668888,
    "name": "web",
    "active": true,
    "events": [
      "push"
    ],
    "config": {
      "content_type": "form",
      "insecure_ssl": "0",
      "url": "https://MYWEBSITE.COM/backend/handle_github_push"
    },
    "updated_at": "2020-06-20T17:06:46Z",
    "created_at": "2020-06-20T17:06:46Z",
    "url": "https://api.github.com/repos/...",
    "test_url": "https://api.github.com/repos/...",
    "ping_url": "https://api.github.com/repos/...",
    "last_response": {
      "code": null,
      "status": "unused",
      "message": null
    }
  },
  "repository": {
    *PROPERTIES OF THE REPO*
  }

According to some of my research, I can rely on the "ref" tag in the payload to determine if it's a master branch. However, clearly there isn't any information given on which branch this event was for.

Am I doing anything wrong here?

knl
  • 969
  • 11
  • 35

1 Answers1

0

You won't see a "ref" key in the webhook event payload if there's only a master branch.

Raj
  • 3,791
  • 5
  • 43
  • 56