Virtualmin and GitLab

I have installed Virtualmin and GitLab on the same Ubuntu 20.04 VPS
Both are working perfect.

I want to make one of the virtual servers in Virtualmin automatically get the changes from one branch in GitLab when any change occurs

Is that possible?

Have you experimented with Virtualmin’s feature of enabling Git repositories on your virtualhosts? Then you could just set up the Gitlab repo as a remote to the virtualhost’s git repo, and set your document root as the folder containing that branch (this may also be useful in this case, github - Git - Different Remote for each Branch - Stack Overflow).

EDIT: I think I got that backwards. You would set your virtualhost’s repo as a remote for your Gitlab branch. Then pushing to that branch would send changes to your virtualhost.

Thanks for reply

I was hoping for something like a webhook
But If you think your way will do the same, I wish if you can tell me more details, or how to do it step.

Thanks again

I think even in a case where something like webhooks would be useful, they would ultimately need to trigger some underlying automation framework to push the content to your server. This is how things like Github Actions and most CI/CD services like Jenkins (or Gitlab for that matter) work. You would still need to establish the resources needed for these tools, namely the public web directories and an SSH account with access to them and key pair authentication that the automation actions can use.

I’m not immediately aware that a specific solution exists, but I’m sure it’s possible to achieve this kind of setup using nothing but a shell script and native Linux tooling. Essentially, when the branch is updated Gitlab would send a webhook notification to your server which could then pull the latest updates through git or curl commaneds. It seems like a very straightforward kind of task, it would surprise me if there’s not something available off-the-shelf. You may have more luck asking for advice from the Gitlab community (https://forum.gitlab.com/).

I’m pretty familiar with similar kinds of tools, but am still fairly inexperienced with them. I’ve recently been spending the time required to properly learn how to use Ansible, as it would save a lot of monthly expenses on hosting as a result. If this kind of automation is something that would give you even a moderately significant value, I’d encourage you to take on the challenge for picking up those skills, as in my experience they generally translate into opening up new opportunities and providing benefits in other areas I didn’t expect.

I know this isn’t the most useful or easy solution you were probably looking for, but I hope it helps in some measure anyhow. If you find a particular method or tool that you think would work and are need any assistance, post back and let me know. I’m currently working on an adjacent sort of project with setting up automated server deployments via Ansible, I’m sure we’ll get it figured out one way or another.

Thank for your reply

I made a PHP page to receive webhook requests from GitLab
This page create a dummy file I am using only as a flag
Then I created a cronjob to check every minute if the dummy file exists, It deletes it and execute git pull command

This is a dirty workaround but it is working for me now
The only thing that annoying is the delay for about 1 minute