Skip to content

Commit

Permalink
get and set terraform version using version.tf (#726)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewpearce-digital authored Sep 25, 2023
1 parent c773969 commit 5e44313
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
14 changes: 13 additions & 1 deletion .github/workflows/dispatch_change_dns_target_region.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,21 @@ jobs:
run: |
aws ssm put-parameter --name "/modernising-lpa/dns-target-region/${{ github.event.inputs.environment }}" --type "String" --value "${{ github.event.inputs.region }}" --overwrite
- name: Parse terraform version
id: tf_version_setup
working-directory: ./terraform/environment
run: |
if [ -f ./versions.tf ]; then
terraform_version=$(cat ./versions.tf | ../../scripts/terraform-version.sh)
echo "- Terraform version: [${terraform_version}]" >> $GITHUB_STEP_SUMMARY
echo "TERRAFORM_VERSION=${terraform_version}" >> $GITHUB_OUTPUT
fi
- name: "Terraform version [${{ steps.tf_version_setup.outputs.TERRAFORM_VERSION }}]"
run: echo "terraform version [${{ steps.tf_version_setup.outputs.TERRAFORM_VERSION }}]"
working-directory: ./terraform/environment
- uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.5.2
terraform_version: ${{ steps.tf_version_setup.outputs.TERRAFORM_VERSION }}
terraform_wrapper: false
- name: Configure AWS Credentials For Terraform
uses: aws-actions/configure-aws-credentials@v4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,21 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: unfor19/install-aws-cli-action@v1
- name: Parse terraform version
id: tf_version_setup
working-directory: ./terraform/environment
run: |
if [ -f ./versions.tf ]; then
terraform_version=$(cat ./versions.tf | ../../scripts/terraform-version.sh)
echo "- Terraform version: [${terraform_version}]" >> $GITHUB_STEP_SUMMARY
echo "TERRAFORM_VERSION=${terraform_version}" >> $GITHUB_OUTPUT
fi
- name: "Terraform version [${{ steps.tf_version_setup.outputs.TERRAFORM_VERSION }}]"
run: echo "terraform version [${{ steps.tf_version_setup.outputs.TERRAFORM_VERSION }}]"
working-directory: ./terraform/environment
- uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.5.2
terraform_version: ${{ steps.tf_version_setup.outputs.TERRAFORM_VERSION }}
terraform_wrapper: false
- name: Configure AWS Credentials For Terraform
uses: aws-actions/configure-aws-credentials@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/terraform_account_job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- uses: unfor19/install-aws-cli-action@v1
- name: Parse terraform version
id: tf_version_setup
working-directory: ./terraform/environment
working-directory: ./terraform/account
run: |
if [ -f ./versions.tf ]; then
terraform_version=$(cat ./versions.tf | ../../scripts/terraform-version.sh)
Expand All @@ -35,7 +35,7 @@ jobs:
fi
- name: "Terraform version [${{ steps.tf_version_setup.outputs.TERRAFORM_VERSION }}]"
run: echo "terraform version [${{ steps.tf_version_setup.outputs.TERRAFORM_VERSION }}]"
working-directory: ./terraform/environment
working-directory: ./terraform/account
- uses: hashicorp/setup-terraform@v2
with:
terraform_version: ${{ steps.tf_version_setup.outputs.TERRAFORM_VERSION }}
Expand Down

0 comments on commit 5e44313

Please sign in to comment.