Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading