Skip to content

Commit e246dae

Browse files
VIA-102 AJ/AS Adding support for distinguishing local vs GitHub naming
1 parent 1313900 commit e246dae

File tree

9 files changed

+49
-4
lines changed

9 files changed

+49
-4
lines changed

infrastructure/environments/dev/.gitkeep

Whitespace-only changes.

infrastructure/environments/dev/.terraform.lock.hcl

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
data "external" "git_branch" {
2+
program = ["bash", "${path.module}/../../scripts/get_git_branch.sh"]
3+
}
4+
5+
data "external" "deploy_source" {
6+
program = ["bash", "${path.module}/../../scripts/get_deploy_source.sh"]
7+
}

infrastructure/environments/dev/locals.tf

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
locals {
2-
region = "eu-west-2"
2+
region = "eu-west-2"
3+
34
project_identifier = "vaccinations-app"
45
project_identifier_shortcode = "vita"
5-
environment = "dev"
6+
7+
environment = "dev"
8+
git_branch = coalesce(data.external.git_branch.result.output, "main")
9+
deploy_source = coalesce(data.external.deploy_source.result.output, "lo")
10+
611
default_tags = {
712
ManagedBy = "Terraform"
813
Project = local.project_identifier

infrastructure/environments/dev/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ module "deploy" {
22
source = "../../modules/deploy_app"
33

44
open-next-path = "../../../.open-next"
5-
prefix = local.project_identifier_shortcode
5+
prefix = "${local.deploy_source}-${local.git_branch}-${local.project_identifier_shortcode}"
66
default_tags = local.default_tags
77
}

infrastructure/modules/.gitkeep

Whitespace-only changes.

infrastructure/modules/deploy_app/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ variable "open-next-path" {
99
}
1010

1111
variable "default_tags" {
12-
type = string
12+
type = map(string)
1313
description = "Map of default key-value pair of tags to add to resources"
1414
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
if [[ -z "${GITHUB_ACTIONS}" ]]; then
4+
DEPLOY_SOURCE="lo" # local
5+
else
6+
DEPLOY_SOURCE="gh" # github
7+
fi
8+
9+
echo "{\"output\": \"$DEPLOY_SOURCE\"}"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
RAW_BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
4+
BRANCH_NAME=$(echo "$RAW_BRANCH_NAME" | sed 's|/|-|g' | tr '[:upper:]' '[:lower:]')
5+
echo "{\"output\": \"${BRANCH_NAME:0:10}\"}"

0 commit comments

Comments
 (0)