Question

How to automatically deploy my code from a GitLab repo to my droplet?

Posted January 7, 2019 7.5k views
Git Deployment Ubuntu 18.04

Hi! I’ve been looking into GitLab’s CI/CD features recently and I can’t seem to understand how to automatically deploy files from my master branch to my droplet. Can anyone help me out here and explain it? I’m pretty new to CI/CD. Thanks!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

1 answer

Hey friend,

So this is a bit open ended. There’s no one right way to do this, and I’d propose no wrong way either. Personally I create bash scripts to update code on my systems over Git, but my ways tend to make others cringe. For example, I run this on a 5 minute cron on a bunch of my servers:

https://github.com/mxroute/MX-Scripts/blob/master/update_manager.sh

Here’s an example of how someone else deploys their code:

https://gist.github.com/noelboss/3fe13927025b89757f8fb12e9066f2fa

Another still:

https://medium.com/@francoisromain/vps-deploy-with-git-fea605f1303b

Pretty much any way that fits your needs and doesn’t cause problems, I’d call it the right answer :)

Jarland

Submit an Answer