github-bots/

directory
v0.6.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2024 License: Apache-2.0

README

github-bots

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
  }
}

Requirements

No requirements.

Providers

Name Version
google n/a

Modules

Name Source Version
cloudevent-trigger chainguard-dev/common/infra//modules/cloudevent-trigger n/a
dashboard chainguard-dev/common/infra//modules/dashboard/cloudevent-receiver n/a
service chainguard-dev/common/infra//modules/regional-go-service n/a

Resources

Name Type
google_service_account.sa resource

Inputs

Name Description Type Default Required
broker A map from each of the input region names to the name of the Broker topic in that region. map(string) n/a yes
github-event The GitHub event type to subscribe to. string n/a yes
name The name of the bot. string n/a yes
notification_channels List of notification channels to alert. list(string) n/a yes
project_id Project ID to create resources in. string n/a yes
regions A map from region names to a network and subnetwork.
map(object({
network = string
subnet = string
}))
n/a yes
source_code The source code for the bot.
object({
working_dir = string
importpath = string
})
n/a yes

Outputs

Name Description
serviceaccount-email The ID of the service account for the bot.
serviceaccount-id The ID of the service account for the bot.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL