From eb01de02853247447fd275d1d1a94e6128e62487 Mon Sep 17 00:00:00 2001 From: Jamil Date: Tue, 12 Mar 2024 10:13:31 -0700 Subject: [PATCH] chore(ci): Use tool versions action to parse terraform version (#4076) Extracted from feedback on #4049 --- .github/workflows/_deploy_production.yml | 10 +++++----- .github/workflows/_terraform.yml | 10 +++++----- .github/workflows/cd.yml | 10 +++++----- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/_deploy_production.yml b/.github/workflows/_deploy_production.yml index 724bcf9cc..e4986a621 100644 --- a/.github/workflows/_deploy_production.yml +++ b/.github/workflows/_deploy_production.yml @@ -76,13 +76,13 @@ jobs: TF_API_TOKEN: "${{ secrets.TF_API_TOKEN }}" TF_WORKSPACE: "production" steps: - - name: Get Terraform Version - run: | - TERRAFORM_VERSION=$(cat .tool-versions | grep terraform | awk '{ print $NF; }') - echo "TERRAFORM_VERSION=${TERRAFORM_VERSION}" >> $GITHUB_ENV + - uses: actions/checkout@v4 + - name: Tool Versions + id: versions + uses: marocchino/tool-versions-action@v1.2.0 - uses: hashicorp/setup-terraform@v3 with: - terraform_version: ${{ env.TERRAFORM_VERSION }} + terraform_version: ${{ steps.versions.outputs.terraform }} - uses: actions/checkout@v4 with: ref: ${{ github.event.workflow_run.head_branch }} diff --git a/.github/workflows/_terraform.yml b/.github/workflows/_terraform.yml index ddff61418..fda62bc82 100644 --- a/.github/workflows/_terraform.yml +++ b/.github/workflows/_terraform.yml @@ -17,13 +17,13 @@ jobs: TF_API_TOKEN: "${{ secrets.TF_API_TOKEN }}" TF_WORKSPACE: "staging" steps: - - name: Get Terraform Version - run: | - TERRAFORM_VERSION=$(cat .tool-versions | grep terraform | awk '{ print $NF; }') - echo "TERRAFORM_VERSION=${TERRAFORM_VERSION}" >> $GITHUB_ENV + - uses: actions/checkout@v4 + - name: Tool Versions + id: versions + uses: marocchino/tool-versions-action@v1.2.0 - uses: hashicorp/setup-terraform@v3 with: - terraform_version: ${{ env.TERRAFORM_VERSION }} + terraform_version: ${{ steps.versions.outputs.terraform }} - uses: actions/checkout@v4 - name: Validate cloud-init run: | diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 2a8a7558e..e45120051 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -41,13 +41,13 @@ jobs: TF_API_TOKEN: "${{ secrets.TF_API_TOKEN }}" TF_WORKSPACE: "staging" steps: - - name: Get Terraform Version - run: | - TERRAFORM_VERSION=$(cat .tool-versions | grep terraform | awk '{ print $NF; }') - echo "TERRAFORM_VERSION=${TERRAFORM_VERSION}" >> $GITHUB_ENV + - uses: actions/checkout@v4 + - name: Tool Versions + id: versions + uses: marocchino/tool-versions-action@v1.2.0 - uses: hashicorp/setup-terraform@v3 with: - terraform_version: ${{ env.TERRAFORM_VERSION }} + terraform_version: ${{ steps.versions.outputs.terraform }} - uses: actions/checkout@v4 with: ref: ${{ github.event.workflow_run.head_branch }}