Pradeep Chandran
Pradeep Chandran

Reputation: 337

How to get git hub push events using curl

I need to fetch all push events in my remote repo for my organization with curl or git api. I cannot use the web hook feature in GitHub because my webhook server is running behind a firewall.So github.com cannot call my webhook url.i need to get the webhook payload using curl

when i try:-

curl -X GET -u $GITHUB_USER:$GITHUB_PASSWORD https://api.github.com/repos/:org/:repo/events

getting all events like push and create,i only need push events

Upvotes: 3

Views: 629

Answers (1)

Z4-tier
Z4-tier

Reputation: 7978

You can pipe the output of that curl command to jq and pick out just the events with type PushEvent, like this:

curl \
    -X GET \
    -u $GITHUB_USER:$GITHUB_PASSWORD \
    https://api.github.com/repos/:org/:repo/events \
  | jq '.[] | select(.type == "PushEvent")'

Note that the second | pipe is inside '' single-quotes as it part of the arguments to jq. It is not for the shell.

Upvotes: 2

Related Questions