There are some tools available to help you with that, like Capistrano, but I could not find one, written in PHP, which was able to do it via github/bitbucket hooks, so I built a package to help me with that: https://github.com/antonioribeiro/deeployer.
It uses Laravel Envoy to provide some scripting to your deployment process.
Using Envoy make it easy to run your tasks manually in the command line by doing:
cd <your deployer directory>
envoy run <task name>
An example would be:
envoy run https://github.com/antonioribeiro/deeployer:master