Skip to content

Commit

Permalink
fix: cloud build trigger regex to only match the correct branches (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
rjerrems authored Aug 6, 2020
1 parent b933b9b commit f555239
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions modules/cloudbuild/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ locals {
cloudbuild_apis = ["cloudbuild.googleapis.com", "sourcerepo.googleapis.com", "cloudkms.googleapis.com"]
impersonation_enabled_count = var.sa_enable_impersonation == true ? 1 : 0
activate_apis = distinct(var.activate_apis)
apply_branches_regex = "(${join("|", var.terraform_apply_branches)})"
plan_branches_regex = "[^${join("|", var.terraform_apply_branches)}]"
apply_branches_regex = "^(${join("|", var.terraform_apply_branches)})$"
}

resource "random_id" "suffix" {
Expand Down Expand Up @@ -204,8 +203,9 @@ resource "google_cloudbuild_trigger" "non_master_trigger" {
description = "${each.value} - terraform plan."

trigger_template {
branch_name = local.plan_branches_regex
repo_name = each.value
invert_regex = true
branch_name = local.apply_branches_regex
repo_name = each.value
}

substitutions = {
Expand Down

0 comments on commit f555239

Please sign in to comment.