main branch will automatically build and publish your Docker image.
Pipeline Overview
| Step | Action | Outcome |
|---|---|---|
| 1 | Define Build Steps | Update cloudbuild.yaml with build & push instructions. |
| 2 | Commit to GitHub | Push your pipeline code to the GitHub repository. |
| 3 | Open a Pull Request | Request review by targeting the main branch. |
| 4 | Merge into Main | Approved PR merge triggers the pipeline. |
| 5 | Execute Cloud Build | Cloud Build runs automatically on the new commit. |
| 6 | Build & Push Docker Image | Image is built and published to Artifact Registry. |
Ensure your GitHub repo is connected to Cloud Build and you have permissions on the Artifact Registry.
1. Update cloudbuild.yaml
Place this file in the root of your repository to define your build pipeline. Example configuration:
2. Commit to GitHub
Save your changes and push to a feature branch:3. Open a Pull Request
In GitHub, open a PR fromfeature/ci-cd-setup into main. Assign reviewers to validate:
- Review
cloudbuild.yaml - Check naming and region settings
- Verify IAM permissions for Cloud Build
4. Merge into Main
Once approved, merge the PR. Cloud Build only triggers on commits to themain branch.
Avoid merging untested changes directly into
main. Always validate in a staging or development branch first.5. Trigger Cloud Build
After merging, Cloud Build detects the new commit onmain and executes your defined steps. Monitor builds via:
6. Build and Publish Docker Image
Cloud Build will:- Build the Docker image.
- Push it to Artifact Registry in the specified region (e.g.,
us-central1).