From c99dc2c8aae85f6973f84b286262b3296bd6f99a Mon Sep 17 00:00:00 2001 From: Martin Hutchinson Date: Thu, 22 Feb 2024 15:34:13 +0000 Subject: [PATCH] Slack notifications are filtered to channels based on env (#106) 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. --- deployment/modules/cloudbuild/main.tf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/deployment/modules/cloudbuild/main.tf b/deployment/modules/cloudbuild/main.tf index aba76ad..922c089 100644 --- a/deployment/modules/cloudbuild/main.tf +++ b/deployment/modules/cloudbuild/main.tf @@ -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