I will be creating a gitlab server at my school to host class code. I wish to make it so that every time any user pushes to gitlab it automatically deploys the project to /var/www/gitdeploy/<repo-user>/<repo>/<branch>
, in such a way that http://<myServer>/gitdeploy/<repo-user>/<repo>/<branch>
is accessible.
Preferably it would deploy all branches, but at minimum the master would be fine. All this will be running on the same server.
I heard of Gitlab CI, but wasn't to sure it was for me, and I did not understand how to set it up.
How could I do this?
EDIT:
Also, I guess I should specify that I want it for ALL users, hopefully without me configuring it for each user, ice globaly
Best Answer
You could do it with a git server-side hook (such as
post-receive
) that deploys your code. Gitlab CI is designed for this, however, and you should consider using it.If you go with a hook, the hook will be a shell script in
.git/hooks/post-receive/
. It will need deployment credentials and you will need to write it yourself. However, that is one use case of hooks. Check out the documentation: https://git-scm.com/book/en/v2/Customizing-Git-Git-HooksAlso see the gitlab-specific documentation: http://doc.gitlab.com/ce/hooks/custom_hooks.html