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

Posted January 7, 2019 14.9k views
GitDeploymentUbuntu 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.

Submit an Answer
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:

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

Another still:

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