Skip to content

Commit 1c39a93

Browse files
authored
Merge pull request #3 from chris-qa-org/add-github-action-to-check-terraform-version-mismatch
Add GitHub action to check terraform version mismatch
2 parents 3612ad1 + 90fa7a8 commit 1c39a93

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

.github/workflows/main.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ jobs:
1313
- name: Check out code
1414
uses: actions/checkout@v1
1515

16+
- name: Check for terraform version mismatch
17+
run: |
18+
DOTFILE_VERSION=$(cat .terraform-version)
19+
TERRAFORM_IMAGE_REFERENCES=$(grep "uses: docker://hashicorp/terraform" .github/workflows/main.yml | grep -v TERRAFORM_IMAGE_REFERENCES | wc -l | tr -d ' ')
20+
if [ "$(grep "docker://hashicorp/terraform:${DOTFILE_VERSION}" .github/workflows/main.yml | wc -l | tr -d ' ')" != "$TERRAFORM_IMAGE_REFERENCES" ]
21+
then
22+
echo -e "\033[1;31mError: terraform version in .terraform-version file does not match docker://hashicorp/terraform versions in .github/workflows/main.yml"
23+
exit 1
24+
fi
25+
1626
- name: Run a Terraform init
1727
uses: docker://hashicorp/terraform:1.1.5
1828
with:

0 commit comments

Comments
 (0)