Skip to content

Commit

Permalink
Slack notifications are filtered to channels based on env (#106)
Browse files Browse the repository at this point in the history
Builds triggered by the -dev trigger go to cloudbuild-dev, and ones from the -prod trigger go to the public channel. This cuts down on a lot of duplicate noise, and means that we can test in dev without creating concern that everything is broken on the public channel.

Note that the first parts of the filter are all the same as the default value for this predicate. The only diff is the trigger.endsWith.
  • Loading branch information
mhutchinson authored Feb 22, 2024
1 parent b49207c commit c99dc2c
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions deployment/modules/cloudbuild/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ module "cloud-build-slack-notifier" {
name = "gcp-slack-${var.env}"
project_id = var.project_id

cloud_build_event_filter = "build.substitutions['BRANCH_NAME'] == 'main' && build.status in [Build.Status.SUCCESS, Build.Status.FAILURE, Build.Status.TIMEOUT] && build.substitutions['TRIGGER_NAME'].endsWith('-${var.env}')"

# https://api.slack.com/apps/A06KYD43DPE/incoming-webhooks
slack_webhook_url_secret_id = "gcb_slack_webhook_${var.env}"
slack_webhook_url_secret_project = var.project_id
Expand Down

0 comments on commit c99dc2c

Please sign in to comment.