GitLab PHP Website Deployment

deployment, git, gitlab, hook

Solution

With Gitolite, which is used by GitLab, you must declare your post-receive hook as VREF (that I detail here).

That supposes that your `.gitolite.rc` contains a `LOCAL_CODE` variable (see this script) in order to store your VREFs in a directory of your choice.

Then you can associate that VREF (which is just an hook executable) to one or many repo in the `gitolite.conf` of the `gitolite-admin` repo. (manually, since there is no interface for that through GitLab)

Problem

I've setup GitLab and am using it to host my Git repositories. Now what I'm trying to do is setup a `post-receive` hook so that I can develop in a folder called `site_dev` then push my changes so they're automatically pulled into the `site` folder. All morning I've been trying to get this hook to work however I've not had any luck executing any commands with GitLab running on Ubuntu Server, I know that the `resque` service is running and my workers are active. Currently I have: ``` #!/bin/bash LIVE="/var/www/teamnet" # read oldrev newrev refname # if [ $refname = "refs/heads/master" ]; then echo "===== DEPLOYING TO LIVE SITE =====" cd $LIVE || exit unset GIT_DIR git pull echo "===== DONE =====" # fi ``` Attempting to pull my changes. I'm not sure whether I've done something wrong here... All folders are in the same location `/var/www/` on the same server. And yes, I have ran `chmod +x` on the hook. Yes, I've ran `git init --bare` for the live folder and set the origin to the Git repository. I'm a little confused however as to where this hook should live, the live/dev folder?

Original source

Related problems