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

January 7, 2019 4.3k 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!

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 :)


Have another answer? Share your knowledge.