GCP DevOps Project
Sprint 04
Connecting Github repo to cloudbuild
Automate your CI/CD pipeline by linking GitHub with Google Cloud Build. Whenever you push code, Cloud Build can kick off your build and deployment processes without manual intervention.
Warning
Make sure billing is enabled on your Google Cloud project. Builds will fail if billing isn’t set up.
Prerequisites
Requirement | Details |
---|---|
Google Cloud Project | Active project with billing enabled |
IAM Role | roles/editor or roles/cloudbuild.builds.editor |
GitHub Account | Owner or admin access to the target repository |
1. Verify Your GCP Project
- Sign in to the Google Cloud Console.
- Confirm you’re working in the correct project.
2. Enable the Cloud Build API
- In the top search bar, type Cloud Build and select it.
- If you haven’t used Cloud Build here before, click Enable.
- Wait a minute for the API to be provisioned, then navigate back to Cloud Build.
3. Explore the Cloud Build Dashboard
- From the left-hand menu, choose Dashboard.
- You’ll see that no builds have run yet.
- Optionally, set your build region; otherwise leave the default global.
4. Create a Build Trigger
Cloud Build triggers start builds automatically on repository events.
- In the left navigation pane, click Triggers.
- Select Manage repositories to view connected source repositories (initially empty).
5. Connect Your GitHub Repository
- On Manage repositories, click Connect repository.
- Choose GitHub and press Continue—you’ll be redirected to GitHub for authentication.
- On GitHub:
- Install the Google Cloud Build app.
- Select Only select repositories and pick your repo (e.g.,
GCP DevOps project
). - Click Install and authorize.
- Return to the Cloud Console:
- Verify your GitHub account and repository selection.
- Accept terms and click Connect.
- Optionally, skip trigger creation by clicking Done for now.
6. Verify the Connection
Back on Manage repositories, your GitHub repo should now appear. This confirms Cloud Build is linked and ready for triggers.
Next, you’ll create a cloudbuild.yaml
file to define your build steps—compiling code, running tests, and pushing Docker images automatically.
Further Reading
Watch Video
Watch video content