This module has scaffolding for event-driven GitHub bots. This integrates with github-events to receive events, and provides SDK methods to interact with GitHub resources. The Terraform module creates a service account for the bot, and deploys the bot as a regional service.
Out-of-the-box bots include:
dnm: A bot that adds or removes a blocking/dnm label on pull requests if the title contains the text "do not merge".
blocker: A bot that passes or fails a GitHub Check Run based on the presence of a blocking/* label on a pull request.
this check can be used to block merges in GitHub.
// ... networking and cloudevent-broker modules...
module "github-events" {
source = "./modules/github-events"
project_id = var.project_id
name = "github-events"
regions = module.networking.regional-networks
ingress = module.cloudevent-broker.ingress
// Which user is allowed to populate webhook secret values.
secret_version_adder = "user:you@company.biz"
}
module "bots" {
source = "./modules/github-bots"
for_each = {
"dnm" = "dev.chainguard.github.pull_request",
"blocker" = "dev.chainguard.github.pull_request",
}
project_id = var.project_id
regions = module.networking.regional-networks
broker = module.cloudevent-broker.broker
name = each.key
github-event = each.value
source_code = {
importpath = "./${each.key}"
}
}
module "my-custom-bot" {
source = "./modules/github-bots"
project_id = var.project_id
regions = module.networking.regional-networks
broker = module.cloudevent-broker.broker
name = "my-custom-bot"
github-event = "dev.chainguard.github.pull_request"
source_code = {
importpath = "./cmd/custom/bot"
working_dir = path.module
}
}