CI integration for Github App and Google Cloud Build
Docker Hub
docker pull neojrotary/gcb-bridge
We want to use amazing GCB with Github CheckRun but...
- GCB Github App cant manage triggers
- GCB doesn't support triggers inside configuration yaml
before Google support them, we make a small app to handle it ( at 2018/09/06). This Project will be deprecated when Google support them.
- Integration with Github CheckRun on commits.
- Check Build Log at CheckRun detail without access GCB.
- Multi-Builds in one configuration yaml.
- Define triggers inside configuration yaml.
- Triggers can be set at both
build
andstep
. - Trigger by
branch
,tag
,pull request
and filtering by file changes.
Prepare cloudbuild.bridge.yaml
at root of repository. You can
- Define
name
for each build, it will be showed at Github CheckRun. - Separate builds by
---
. - Put
triggers
at build and step. - Each build follow "Cloud Build build configuration". Check Build Configuration Overview
For example:
name: 'test branch'
triggers:
- branches: []
steps:
- name: ''
triggers:
- includedFiles: []
- name: ''
---
name: 'new release'
triggers:
- tags: []
steps:
- name: ''
- name: ''
images:
- [...]
artifacts:
triggers
is an array of trigger Object
, a triggers
is passed if any of trigger Object
is passed. Each trigger Object
takes same concept of "GCB Build Triggers".
triggers:
- branches: []
tags: []
pullRequestBases: []
includedFiles: []
ignoredFiles: []
- ... trigger Object...
- ... trigger Object...
branches
: array of regex
Match branch by regex.tags
: array of regex
Match tag by regex.pullRequestBases
: array of regex
Match Pull-Request's base branch by regex.includedFiles
: array of glob
Match file changes by glob. It works by itself even there is no anybranches
,tag
,pullRequestBases
.ignoredFiles
: array of glob
Ignore file changes by glob.
- Prepare your private Github App. Check Creating a GitHub App. Since it is a private App, the only URL you need to setup correctly is
Webhook URL
. Server will listen on/webook
so it would be likehttps://sub.domain.com/webhook
. - Prepare your Google Cloud Platform Project and create a Service Account with
Cloud Build Service Account
,Pub/Sub Subscriber
andStorage Admin
roles. Get credential file in json format. - Deploy container with ENVs to any Engine you like in GCP. Then setup network for receiving Github Webhook.
Enviroment variables for runtime
LISTEN_ON
Address where http server listen on. Default is0.0.0.0:8080
.GITHUB_APP_PRIVATE_KEY
Generated key file from App's settings. Put the content into ENV.GITHUB_APP_ID
Get it from App's settings "About" section.GITHUB_APP_WEBHOOK_SECRET
Your Github app webhook secretGCLOUD_SERVICE_ACCOUNT
GCP service account json file contentGCLOUD_PROJECT_ID
GCP Project IDGCLOUD_STORAGE_BUCKET
GCS bucket name, your log and source file will be uploaded to hereDEBUG
Enable DEBUG mode to print more information to console
If you want to know deep into project. Check DEVELOP.md.
- improve logging
- optional integration with Slack
- support
waitFor
between different builds - support auto cancellation if new build be triggered but previous same build still not finish
- prepare REST API for manully triggering