Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emulate github service hooks wih curl

I have a service listening to github service hooks, to perform automatic deployment. Sometimes I need to trigger this manually (without github intervention). For that, I am emulating the POST request that github is sending (post-receive-URLs).

My data (my.json) looks like this (a limited subset of what github is sending - I do not need more):

{
  "action"      : "deploy_from_scratch_with_bundle",
  "pusher"      : { "email" : "[email protected]" },
  "ref"         : "refs/heads/master"
}

And I try to POST with curl:

curl -X POST $URL --data-urlencode "@my.json" --header "Content-Type: application/x-www-form-urlencoded"

The problem is that github is POSTing like this:

payload=%7B%22pusher%22%3A%7B%22name%22%3A%22none%22%7D%2C%22repository%22%3
A%7B%22name%22%3A%liferay-plugins%22%2C%22created_at%22%3A%222011%2F12%2F07%2011%3A52...

See that payload= there? This looks like a form field. I do not know how to combine form fields with urlencoding. To POST form fields, I would do it like this:

curl -X POST $URL -F "[email protected]"

But the JSON would not be url encoded. How to I get both?

like image 862
blueFast Avatar asked Mar 08 '26 19:03

blueFast


1 Answers

curl $URL --data-urlencode [email protected]

like image 115
rkhayrov Avatar answered Mar 11 '26 09:03

rkhayrov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!