GitHub app triggers allow you to automatically trigger builds on Git pushes and pull requests, and view your build results on GitHub and Cloud Console. Additionally, it supports all the features supported by the existing GitHub triggers. GitHub app triggers uses the Cloud Build GitHub app to configure and authenticate to GitHub.
This page explains how to create GitHub app triggers.
Creating GitHub app triggers
This section explains how to install the Cloud Build GitHub app to connect your GitHub repository to your Cloud project and then create GitHub app triggers.
Installing the Cloud Build app
To install the Cloud Build app and connect your GitHub repository to your Cloud project:
Open the Triggers page in the Google Cloud Console.
In the project selector in the top bar, select your Cloud project.
Click Connect repository.
Select GitHub (Cloud Build GitHub app), check the consent checkbox, and click Continue.
(Optional) If you have not signed into GitHub before, do so now.
The Authorization page appears where you are asked to authorize the Google Cloud Build app to connect to Google Cloud Platform.
Click Authorize Google Cloud Build by GoogleCloudBuild.
Click Install Google Cloud Build.
In the pop-up that appears, select your GitHub username or organization.
Select one of the following options based on your business need:
All repositories - enable all current and future GitHub repositories for access via the Cloud Build app.
Only select repositories - use the Select repositories drop-down to only enable specific repositories for access via the Cloud Build app. You will be able to enable additional repositories at a later time.
Click Install to install the Cloud Build app.
The pop-up closes and you are returned to the Select repository page in the Cloud Console. In this page you will connect your GitHub repositories to your Cloud project.
In the Select repository page that appears, connect your GitHub repositories to your Cloud project as follows:
a. Confirm the correct GitHub account has been selected.
b. Select the checkbox next to each target repository.
c. Read the consent disclaimer and select the checkbox next to it to indicate that you accept the presented terms.
d. Click Connect repository.
If you don't see one or more of your target repositories, click Edit repositories on GitHub and repeat the steps above to enable additional repositories in the Cloud Build app.
(Optional) To create push triggers for the repositories you're connecting, select the boxes next to each target repository and click Create push triggers; otherwise, click Skip for now.
You have now connected one or more GitHub repositories to your Cloud project. You are directed to the Triggers page in Cloud Console.
Creating GitHub app triggers
To create GitHub app triggers:
In the Triggers page, click Create trigger.
Enter the following trigger settings:
Name: A name for your trigger.
Trigger Type: Select one of the following options for trigger type:
- Branch: Set a trigger to start a build on commits to this branch. You can also specify a regular expression with the branch value to match. For information on acceptable regular expression syntax, see RE2 syntax.
- Tag: Set a trigger to start a build on commits that contains this tag. You can also specify a regular expression with the tag value to match. For information on acceptable regular expression syntax, see RE2 syntax.
Pull request: You can set a trigger to start a build on pull requests targeting the branch you want to merge to. This is a new feature that is available only if you create GitHub app triggers.
Included files (optional): Changes to these files will trigger a build.
Ignored files (optional): Changes to these files will not trigger a build.
For more information on Included Files and Ignored Files see Automating Builds using build triggers.
Build Configuration: The
Dockerfileor build config file (located in the GitHub repository connected to this Cloud project) to use for each build that the trigger starts.
To use a Dockerfile for your build configuration, you'll need to specify the Dockerfile directory and supply a name for the resulting image
When you've provided the Dockerfile and image name, you'll see a preview of the
docker buildcommand that your build will execute and a summary of the trigger configuration. Click Create trigger to save the build trigger.
To use a build config file for your build configuration, you'll need to provide the location of a build config file and optionally substitution variables that you want to use.
Once you've set the location, you'll see a summary of the trigger. Click Create trigger to save the build trigger.
You've now created a GitHub app trigger.
Different types of GitHub-based triggers
If your source code is in GitHub, Cloud Build provides two ways by which you can automatically trigger your builds. This section explains the two GitHub-based triggers and compares their features.
GitHub triggers: When you create a GitHub trigger, Cloud Build mirrors your GitHub repository in Cloud Source Repositories and uses the mirrored repository for all its operations. You can create and manage GitHub triggers using the Cloud Console.
GitHub app triggers: This type of trigger uses the Cloud Build GitHub app to configure and authenticate to GitHub. GitHub app triggers allow you to automatically trigger builds on Git pushes and pull requests and view build results on GitHub and Cloud Console. You can create and manage GitHub app triggers using Cloud Console or the Cloud Build API.
The following table compares the features of GitHub triggers and GitHub app triggers:
|Feature||GitHub triggers||GitHub app triggers|
|Trigger builds on pushes to the source code||Yes||Yes|
|Trigger builds on pull requests||No||Yes|
|Create trigger using Cloud Console||Yes||Yes|
|Create trigger using the Cloud Build API||No||Yes|
|Create trigger using the Cloud Build GitHub app||No||Yes|
|View build status on Cloud Console||Yes||Yes|
|View build status on GitHub||No||Yes|
- Learn how to start builds manually in Cloud Build.