Suvro Choudhury
Suvro Choudhury

Reputation: 145

How to push code to webserver every time I make a commit to a branch?

I have a LAMP stack (RHEL 7, apache 2.4) on AWS ec2 instance and my webroot directory is var/www/html. My php code reside in a remote private github repository (note: this is a private repo). I would like to make an automatic deployment such that, everytime I commit to a branch (NOT master, but another branch), the updated php file would be immediately available on webserver.

How to do this in simplest way? Pls note, I have verified we have connectivity to github from aws ec2 instance and we can install git client on ec2 instance.

Upvotes: 0

Views: 240

Answers (1)

David Neiss
David Neiss

Reputation: 8237

Use a client side post-commit hook to push it. See https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks. Don't forget to make the .git/hooks/post-commit file executable and remember that the hook file isn't part of the repo that gets pushed back to the server.

Upvotes: 1

Related Questions