Skip to content

Commit

Permalink
Generating branch-environment-map for Github Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
dukeofgaming committed Sep 9, 2024
1 parent a682bb2 commit 2f144fc
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions iac/terraform/core/branch-environment-map.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"dev":"dev","main":"staging","prod":"production"}
25 changes: 25 additions & 0 deletions iac/terraform/core/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,29 @@ locals {
for pipeline in var.pipelines :
pipeline.environment => pipeline.aws_iam_user.name == null ? true : false
})

branch_environment_map = {
for pipeline in values(var.pipelines):
pipeline.branch => pipeline.environment
}
}

# Create branch-environment-map.json with branches/patterns as keys
# and environments as values

resource "null_resource" "branch_environment_map" {

triggers = {
branches_changed = jsonencode(keys(local.branch_environment_map))
environments_changed = jsonencode(values(local.branch_environment_map))
#always_run = timestamp()
}

provisioner "local-exec" {
command = <<EOF
echo '${jsonencode(local.branch_environment_map)}' \
> branch-environment-map.json
EOF
}

}

0 comments on commit 2f144fc

Please sign in to comment.