Automated deployment with Google Compute Engine and Cloud Build

Requirements

  • A server running on Google Cloud Compute Engine.
  • PM2 installed and running

What is CI/CD ?

CI/CD stands for Continuous Integration and Continuous Deployment.

The process

The pipeline will be as follow :

  • Push on Github main branch
  • Trigger from Google Cloud Build
  • Script pull.sh executed
  • Code pulled on server & server restart

Create a pull.sh file

The pull.sh file is a bash script that will execute 2 tasks :

  • Pull code from Github repository
  • Restart PM2
sudo su roottouch pull.sh sudo vim pull.sh
chmod +x pull.sh
./pull.sh

Create a Google Source Repository

You need to have a Github repository to push code to the main branch.

YAML file

You might have noticed the cloudbuild.yml file in my repository.

Create a trigger

Short reminder of the process :

Verify the entire CI/CD process

When getting from http://34.105.205.74/api/v1/ping we get “pong”

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Beranger Natanelic

Beranger Natanelic

Future Unicorn Founder — Using tech for good