Skip to content

Commit

Permalink
# This is the 1st commit message:
Browse files Browse the repository at this point in the history
fix: fix null previous image tags being provided to rollback step

# This is the commit message #2:

fix: fix null previous image tags being provided to rollback step

fix: tflint errors addressed
  • Loading branch information
fibble committed Nov 28, 2024
1 parent 9e6a459 commit c8f03f1
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 10 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/deploy-environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,16 @@ jobs:
id: init
run: terraform init -no-color -input=false -upgrade

- name: Get Current Versions from Terraform State
id: get_current_versions
run: |
terraform output -json > outputs.json || true
if [ -s outputs.json ] && [ "$(jq -r 'length' outputs.json)" -gt 0 ]; then
jq -r 'to_entries[] | select(.key | startswith("deployed_")) | "\(.key | ltrimstr("deployed_"))=\(.value.value // "")"' outputs.json >> $GITHUB_OUTPUT
else
echo "No outputs found, could be first run"
fi
- name: Select workspace
if: ${{ inputs.workspace }}
run: terraform workspace select -or-create ${{ inputs.workspace }}
Expand Down Expand Up @@ -277,16 +287,6 @@ jobs:
})
}
- name: Get Current Versions from Terraform State
id: get_current_versions
run: |
terraform output -json > outputs.json
echo "api_image_tag=$(jq -r '.api_image_tag.value' outputs.json)" >> $GITHUB_OUTPUT
echo "cli_image_tag=$(jq -r '.cli_image_tag.value' outputs.json)" >> $GITHUB_OUTPUT
echo "selfserve_image_tag=$(jq -r '.selfserve_image_tag.value' outputs.json)" >> $GITHUB_OUTPUT
echo "internal_image_tag=$(jq -r '.internal_image_tag.value' outputs.json)" >> $GITHUB_OUTPUT
echo "assets_version=$(jq -r '.assets_version.value' outputs.json)" >> $GITHUB_OUTPUT
- name: Apply
id: apply
if: ${{ inputs.apply }}
Expand Down
10 changes: 10 additions & 0 deletions infra/terraform/environments/dev/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -506,3 +506,13 @@ module "service" {
]
}
}

resource "null_resource" "deployed_versions" {
triggers = {
deployed_api_image_tag = var.api_image_tag
deployed_internal_image_tag = var.internal_image_tag
deployed_selfserve_image_tag = var.selfserve_image_tag
deployed_cli_image_tag = var.cli_image_tag
deployed_assets_version = var.assets_version
}
}
19 changes: 19 additions & 0 deletions infra/terraform/environments/dev/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
output "deployed_api_image_tag" {
value = null_resource.deployed_versions.triggers["deployed_api_image_tag"]
}

output "deployed_internal_image_tag" {
value = null_resource.deployed_versions.triggers["deployed_internal_image_tag"]
}

output "deployed_selfserve_image_tag" {
value = null_resource.deployed_versions.triggers["deployed_selfserve_image_tag"]
}

output "deployed_cli_image_tag" {
value = null_resource.deployed_versions.triggers["deployed_cli_image_tag"]
}

output "deployed_assets_version" {
value = null_resource.deployed_versions.triggers["deployed_assets_version"]
}
4 changes: 4 additions & 0 deletions infra/terraform/environments/dev/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ terraform {
source = "hashicorp/aws"
version = ">= 5.72.1"
}
null = {
source = "hashicorp/null"
version = "~> 3.2"
}
}

required_version = ">= 1.0"
Expand Down
10 changes: 10 additions & 0 deletions infra/terraform/environments/int/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -472,3 +472,13 @@ module "service" {
]
}
}

resource "null_resource" "deployed_versions" {
triggers = {
deployed_api_image_tag = var.api_image_tag
deployed_internal_image_tag = var.internal_image_tag
deployed_selfserve_image_tag = var.selfserve_image_tag
deployed_cli_image_tag = var.cli_image_tag
deployed_assets_version = var.assets_version
}
}
19 changes: 19 additions & 0 deletions infra/terraform/environments/int/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
output "deployed_api_image_tag" {
value = null_resource.deployed_versions.triggers["deployed_api_image_tag"]
}

output "deployed_internal_image_tag" {
value = null_resource.deployed_versions.triggers["deployed_internal_image_tag"]
}

output "deployed_selfserve_image_tag" {
value = null_resource.deployed_versions.triggers["deployed_selfserve_image_tag"]
}

output "deployed_cli_image_tag" {
value = null_resource.deployed_versions.triggers["deployed_cli_image_tag"]
}

output "deployed_assets_version" {
value = null_resource.deployed_versions.triggers["deployed_assets_version"]
}
4 changes: 4 additions & 0 deletions infra/terraform/environments/int/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ terraform {
source = "hashicorp/aws"
version = ">= 5.72.1"
}
null = {
source = "hashicorp/null"
version = "~> 3.2"
}
}

required_version = ">= 1.0"
Expand Down

0 comments on commit c8f03f1

Please sign in to comment.