GCP CI/CD Pipeline: Build Docker images after commits to a repo branch (Github)

In this article we will learn how to create a CI/CD pipeline on GCP using Cloud Build, Github, and Docker.

For this article I will be using this repository.

 

1. Create a trigger

First we would need to navigate to Code Build. Select the T…


This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by Andrey Frol

In this article we will learn how to create a CI/CD pipeline on GCP using Cloud Build, Github, and Docker.

For this article I will be using this repository.

 

1. Create a trigger

First we would need to navigate to Code Build. Select the Triggers tab in the sidebar and Create Trigger:

GCP CI/CD pipeline using Code Build, Docker, and Github. Creating a trigger pt1

Enter the name of your trigger and select Connect new repository in the Source section:

GCP CI/CD pipeline using Code Build, Docker, and Github. Attaching Github repository to Cloud Build pt1

You will see a sidebar that will appear on the right hand side with different options for repositories supported by Cloud Build. I am using Github, so I selected the first option. Click Continue:

GCP CI/CD pipeline using Code Build, Docker, and Github. Attaching Github repository to Cloud Build pt2

You will be asked to authorize Cloud Build to access your github account and repositories:

GCP CI/CD pipeline using Code Build, Docker, and Github. Attaching Github repository to Cloud Build pt3

Select your github account and repository for this trigger:

GCP CI/CD pipeline using Code Build, Docker, and Github. Attaching Github repository to Cloud Build pt4

Then select the Dockerfile in the Configuration section and hit Create at the bottom of the page:

GCP CI/CD pipeline using Code Build, Docker, and Github. Creating a trigger pt2

You should see your newly created trigger with the connected repo:

GCP CI/CD pipeline using Code Build, Docker, and Github. Creating a trigger pt3

 

2. Run trigger manually

Let's test our trigger by running it manually first.
Next to your trigger there is a button RUN:

GCP CI/CD pipeline using Code Build, Docker, and Github. Running trigger manually pt1

A sidebar will popup on the right hand side asking you to confirm the details of deployment. Press Run Trigger:

GCP CI/CD pipeline using Code Build, Docker, and Github. Running trigger manually pt2

I can see the new image in the Container Registry. Mine is called github.com. But it is there. The trigger is working!

GCP CI/CD pipeline using Code Build, Docker, and Github. Running trigger manually pt3

GCP CI/CD pipeline using Code Build, Docker, and Github. Running trigger manually pt4

 

3. Run trigger automatically

And finally, let's push new code to the repository and test the trigger for automatic build.

I will let reader do the code pushing.

If you want to see current or past builds, Code Build has a section called History in the sidebar on the left. It is a great to monitor builds.

When I pushed new code to my repository a new build was triggered right away and it appeared in the History section:

GCP CI/CD pipeline using Code Build, Docker, and Github. Running trigger automatically pt4

 

That's it! Thank you for reading.


This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by Andrey Frol


Print Share Comment Cite Upload Translate Updates
APA

Andrey Frol | Sciencx (2022-09-23T18:08:59+00:00) GCP CI/CD Pipeline: Build Docker images after commits to a repo branch (Github). Retrieved from https://www.scien.cx/2022/09/23/gcp-ci-cd-pipeline-build-docker-images-after-commits-to-a-repo-branch-github/

MLA
" » GCP CI/CD Pipeline: Build Docker images after commits to a repo branch (Github)." Andrey Frol | Sciencx - Friday September 23, 2022, https://www.scien.cx/2022/09/23/gcp-ci-cd-pipeline-build-docker-images-after-commits-to-a-repo-branch-github/
HARVARD
Andrey Frol | Sciencx Friday September 23, 2022 » GCP CI/CD Pipeline: Build Docker images after commits to a repo branch (Github)., viewed ,<https://www.scien.cx/2022/09/23/gcp-ci-cd-pipeline-build-docker-images-after-commits-to-a-repo-branch-github/>
VANCOUVER
Andrey Frol | Sciencx - » GCP CI/CD Pipeline: Build Docker images after commits to a repo branch (Github). [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/09/23/gcp-ci-cd-pipeline-build-docker-images-after-commits-to-a-repo-branch-github/
CHICAGO
" » GCP CI/CD Pipeline: Build Docker images after commits to a repo branch (Github)." Andrey Frol | Sciencx - Accessed . https://www.scien.cx/2022/09/23/gcp-ci-cd-pipeline-build-docker-images-after-commits-to-a-repo-branch-github/
IEEE
" » GCP CI/CD Pipeline: Build Docker images after commits to a repo branch (Github)." Andrey Frol | Sciencx [Online]. Available: https://www.scien.cx/2022/09/23/gcp-ci-cd-pipeline-build-docker-images-after-commits-to-a-repo-branch-github/. [Accessed: ]
rf:citation
» GCP CI/CD Pipeline: Build Docker images after commits to a repo branch (Github) | Andrey Frol | Sciencx | https://www.scien.cx/2022/09/23/gcp-ci-cd-pipeline-build-docker-images-after-commits-to-a-repo-branch-github/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.