# Create a webhook to automate pull events on remote server

**URL:** <https://forum.gitea.com/t/create-a-webhook-to-automate-pull-events-on-remote-server/1369>\
**Category:** General\
**Created:** [August 10, 2019, 7:27pm UTC](https://forum.gitea.com/t/create-a-webhook-to-automate-pull-events-on-remote-server/1369 "2019-08-10T19:27:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![trnc](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/trnc/32/612_2.png) [@trnc](https://forum.gitea.com/u/trnc)\
**Post date:** [August 10, 2019, 7:27pm UTC](https://forum.gitea.com/t/create-a-webhook-to-automate-pull-events-on-remote-server/1369/1 "2019-08-10T19:27:44Z")

</div>

Hello!

Just as the title reads… anyone has done a similar task?? I tried to do it by my self with no good results, I’m running Gitea 1.9.0+dev-311-gfb4438a81 on a VPS.

I did as follows… Created a webhook under the repository configuration and pointed the Target URL to my VPS: _[http://123.456.78.9/pull.php](http://123.456.78.9/pull.php)_, the rest of the webhook config is the default, HTTP Method, POST Content Type and so on.

On the server, I’ve created the file **pull.php** with this content

_\<?php_  
_if ($\_POST[‘payload’]) {_

- shell\_exec(‘cd /path/to/the/project/ && git reset --hard HEAD && git pull’);\*
- echo ‘Execution Success’;\*  
_} else {_
- echo ‘Execution Failed’;\*  
_}_  
_?\>_

When I do git push the pull.php it’s supposed to catch the data, but if I do **var\_dump($\_POST);** instead the code above it returns

array(0){  
}

Any help would be appreciated

regards

---

<div class="post-metadata">

**Author:** ![elfuego](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/elfuego/32/4746_2.png) [@elfuego](https://forum.gitea.com/u/elfuego)\
**Post date:** [August 12, 2019, 10:51am UTC](https://forum.gitea.com/t/create-a-webhook-to-automate-pull-events-on-remote-server/1369/2 "2019-08-12T10:51:52Z")

</div>

Try to look at what it sent to your page.  
Go to \<your\_repo\> -\> Settings -\> Webhooks, then click at your webhook, then scroll to the end of the page, to ’ Recent Deliveries’, then click to the latest (upper) one. There you can see exact headers and content which were sent to you page.

---

<div class="post-metadata">

**Author:** ![BasicBaer](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/basicbaer/32/600_2.png) [@BasicBaer](https://forum.gitea.com/u/BasicBaer)\
**Post date:** [August 13, 2019, 6:38am UTC](https://forum.gitea.com/t/create-a-webhook-to-automate-pull-events-on-remote-server/1369/3 "2019-08-13T06:38:00Z")

</div>

If you don’t mind exposing data too much you could use [https://webhook.site/](https://webhook.site/) as a testing target to check if any data is really sent. Alternatively you could run something like ‘nc -l -p $port’ on the server where you are hosting the php script and then use http://$server:$port as hook target (with $port being an unused port number \>1024 and $server being the FQDN of the server hosting the PHP script). That will give you the raw http request.

---

<div class="post-metadata">

**Author:** ![trnc](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/trnc/32/612_2.png) [@trnc](https://forum.gitea.com/u/trnc)\
**Post date:** [August 14, 2019, 7:10pm UTC](https://forum.gitea.com/t/create-a-webhook-to-automate-pull-events-on-remote-server/1369/4 "2019-08-14T19:10:15Z")

</div>

Thank you both!!

@elfuego actually I did it, I checked all headers content but I’m still not able to catch them. Every time I **git push** I need to log into the VPS go to the project folder and **git pull** the changes, there’s something I’m really missing

@BasicBaer This site sounds good, I’ll give it a try using your advice :D, do you know if this site logs data??

Regards!!

---

<div class="post-metadata">

**Author:** ![BasicBaer](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/basicbaer/32/600_2.png) [@BasicBaer](https://forum.gitea.com/u/BasicBaer)\
**Post date:** [August 15, 2019, 12:41pm UTC](https://forum.gitea.com/t/create-a-webhook-to-automate-pull-events-on-remote-server/1369/5 "2019-08-15T12:41:54Z")

</div>

No, I don’t know if that site is logging data - that was the reason so stating “if you don’t mind exposing data” 🙂

Cheers  
Hendrik
