I am trying to create a post-receive hook in Nodejs to update my server when my Github repo has been updated.
I have done this before in php. I am now using Nodejs and am unsure how it should be acheived.
I have looked at this blog post about setting up nodejs on an ec2 instance. It says:
Create a post-recieve hook that will copy over new code after it’s been pushed to the repository
$ cat > hooks/post-receive
#!/bin/sh
GIT_WORK_TREE=/home/ubuntu/www
export GIT_WORK_TREE
git checkout -f
$ chmod +x hooks/post-receive
I am unsure what exactly the above code is doing and how it should be implemented.
Any ideas on the best way of doing this?
I am running a basic 32-bit Amazon Linux EC2 instance.
A git bare repository doesn’t include the working tree. So to use the files you have to check them out.
putting the above script in (pseudo path) ec2:mybaregitrepo/hooks/post-recieve will cause it to run every time you push to ec2.
Which means:
than:
here is a decent runthrough of setting up a remote bare git repo
http://toroid.org/ams/git-website-howto