Configure Cloud Run with Continuous Integration and Deployment

Before you can continue with this tutorial, you must have your project's repository on github or bitbucket, so that google can access the repository and execute all the necessary commands to add CI/CD to your project.

Cloud Build Configuration

When you are creating your Cloud Run service you must select in the Service Configuration section the option Continuously deploy new revisions from a source repository and click the button SET UP WITH CLOUD BUILD

Cloud Run Configuration with Cloud Build
Cloud Run Configuration with Cloud Build

When you click on the button, you will get a right side menu to configure your repository with Cloud Build, there you must select your provider and repository, in our case we will use Github.

Repository Configuration
Repository Configuration

Once your repository has been validated, we are going to select the branch that we want to deploy in Cloud Run and, in addition, the server construction file, in our case a Dockerfile along with the location of the file.

Branch and Dockerfile Configuration
Branch and Dockerfile Configuration

Cloud Build Triggers

By default, Google Cloud will automatically create push and pull triggers for your repository once the Cloud Run service has been created, so you don't need to take any action within the service.

If you want to know the triggers that have been created, you can go to the left side menu and in the CI/CD section select the option Cloud Build > Triggers and there you can find all the triggers that you have created in your project.

Cloud Build Triggers
Cloud Build Triggers