Deploying a Web Project from Gitlab

I wanted to automatically deploy a web project when any updates are pushed to the gitlab repository. To do so I added a ‘Web Hook’. The Web Hook calls a URL in response to ‘push’ events. I created a PHP page to be called by the Web Hook:

gitlab deploy hooks

So in response to push events gitlab_hook.php is called:

The PHP file calls a Shell script :

All this is dependent on setting the permissions appropriately for the user the web server (e.g. apache, www-data) is running as. It is also necessary to ssh-keygen an RSA key for the ‘apache’ user. The public key can then be added to the ‘Deploy Keys’ section in Gitlab project.

Test the script successfully works as the ‘apache’ user before testing from Gitlab:

This was just a first stab at deploying automatically from Gitlab. A few changes could make it more secure.

Leave a Reply

  • (will not be published)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">