Have a website hosted on Amazon Web Services and I want to run a bash script to automatically build my github project when changes are pushed to the repository. How can my aws linux server detect when my repository is pushed to?
-
possible duplicate of [Deploying with Git/Github](http://stackoverflow.com/questions/9619440/deploying-with-git-github) – Austinh100 Jun 28 '14 at 20:08
-
Not a duplicate. That is unrelated to my problem as far as I can tell. – SteveDeFacto Jun 28 '14 at 21:08
2 Answers
You can use GitHub's Webhooks:
Every GitHub repository has the option to communicate with a web server whenever the repository is pushed to. These “webhooks” can be used to update an external issue tracker, trigger CI builds, update a backup mirror, or even deploy to your production server.
The github-services
project supports a large number of popular services out of the box.
Alternatively, you can use Webhooks yourself to configure an HTTP message to be sent to an arbitrary endpoint when a given event occurs. You would need to configure a service that listens for and responds to GitHub's message on your endpoint.

- 127,765
- 105
- 273
- 257
-
-
Thanks @VonC, I've updated my answer to clarify that the "arbitrary endpoint" must be configured to listen for and respond to GitHub's message. – ChrisGPT was on strike Jun 28 '14 at 20:14
-
I set my webhook to "http://example.com:4444" and I try to listen for it with "nc -l 4444 > filename.out" but I'm not getting anything. Can I only post to a webpage and if so, how can I trigger a bash script with this? – SteveDeFacto Jun 28 '14 at 20:54
-
@SteveDeFacto, you should be able to listen using any tool that understands HTTP, though you'll need to make sure that your endpoint is exposed to GitHub. Their example [uses a tool called `ngrok`](https://developer.github.com/webhooks/configuring/). You may also want to browse [their Testing Webooks](https://developer.github.com/webhooks/testing/) page, which explains how you can view "recent deliveries". – ChrisGPT was on strike Jun 28 '14 at 21:10
You can register a webhook on your GitHub repo in order to trigger a message to your aws server.
But, as mentioned in "Sync the local code to Amazon server through GitHub webhook", that means you have a listener on that AWS server which would listen to such a message.