For my nodejs application, I am trying to run a hook through gitolite which performs the following actions (on the server side):
- Update the repo to take into account the new changes (git fetch + git reset --hard newref)
- Update the application dependencies (bower update, npm update / install)
- Check some basic rules (coding rules, unit tests 100% ok, etc). Basically, it runs something like
grunt test
(jshint, mocha, ...) - Compile everything (
grunt build
) - Run the application
If one of these steps somehow fails, the whole process is stopped, the old application is restored and the push is denied.
My first approach was to add a pre-receive hook to this specific repo, but since it is triggered before the gitolite update hook (which checks about your rights), this was bad anyway.
So I now think about using VREFs which kind of work like a secondary update hook. So I'm pretty sure it would work like this, however it seems VREFs are usually here to perform only some basic checks, and don't intend to be used as something such a full deployment process.
I've done some research and it seems that usually people use a post-receive hook to deploy their app. This means that if something fails, the push is accepted anyway. I really would like to avoid accepting a commit which breaks the application at some point.
Is there a better way to achieve this deployment?