DevOps & SRE
Cloud Build brings advanced CI/CD capabilities to GitHub
If you use continuous integration (CI) or continuous delivery (CD) as part of your development environment, being able to configure and trigger builds based on different repo events is essential to creating git-based advanced CI/CD workflows and multi-environment rollouts. Customizing which builds to run on changes to branches, tags, and pull requests can speed up development, notify teammates when changes are ready to be merged, and deploy merged changes to different environments.
Today, millions of developers collaborate on GitHub. To help make these developers more productive, we are excited to launch enhanced features to the Cloud Build GitHub App. Here is a list of the advanced capabilities you gain with Cloud Build’s new features.
Trigger builds on specific pull request, branch, and tag events
When integrating with GitHub via the app, you can now create build triggers to customize which builds to run on specific repo events. For example, you can set up build triggers to fire only on pull requests (PRs), pushes to master, or release tags. You can further specify different build configs to use for each trigger, letting you customize which build steps to run depending on the branch, tag, or PR the change was made to.
You can further customize build triggers by configuring them to run, or not run, based on which files have changed. This lets you, for example, ignore a change to a README file, or only trigger a build when a file in a particular subdirectory has changed (as in a monorepo setup). Lastly, for PRs, an optional feature lets you require a comment on the PR to trigger a build, such that only repo owners and collaborators, and not external contributors, can invoke a build.
If you already use the build trigger feature within Cloud Build, many of these options will look familiar. With this update, we are extending build triggers to support new capabilities, such as GitHub PR events, to developers who use GitHub and want more granular control to create advanced CI/CD pipelines with Cloud Build.
View build status in GitHub
Integrating CI feedback into your developer tools is critical to maintaining your development flow. Builds triggered via the GitHub App automatically post status back to GitHub via the GitHub Checks API. The feedback is integrated directly into the GitHub developer workflow, reducing context switching.
Updates posted to GitHub include build status, build duration, error messages, and a link to detailed build logs. With GitHub protected branches you can now easily use Cloud Build to gate merges on build status and re-run builds directly from the GitHub UI.
Create and manage triggers programmatically
As the number of build triggers in your environment grows, creating and updating triggers from the UI can become time-consuming and hard to manage. With the Cloud Build GitHub App update, you can now configure build triggers via the Cloud Build API or Cloud SDK. Either inline in the API request or via a json or yaml file, you can programmatically create, update, and delete GitHub triggers to more easily manage build triggers across a large team or when automating the CI/CD setup for new repos.
Create a local trigger.yaml file:
description: "Trigger on any PR targeting master"
Import the trigger via the CLI:
$ gcloud beta builds triggers import --source=trigger.yaml
With this integration between Cloud Build and GitHub, you now have an easy way to validate your pull requests early and often and set up more advanced git-based CI/CD workflows. The ability to create triggers in Google Cloud Console or programmatically via config files makes it easy to get started and automate your end-to-end developer workflows. To learn more, check out the documentation, or try this Codelab.