-
Notifications
You must be signed in to change notification settings - Fork 2
60 lines (53 loc) · 1.81 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
name: Terraform CI
on:
push:
branches: main
pull_request:
jobs:
validate-terraform:
name: Validate Terraform
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Check for terraform version mismatch
run: |
DOTFILE_VERSION=$(cat .terraform-version)
TERRAFORM_IMAGE_REFERENCES=$(grep "uses: docker://hashicorp/terraform" .github/workflows/main.yml | grep -v TERRAFORM_IMAGE_REFERENCES | wc -l | tr -d ' ')
if [ "$(grep "docker://hashicorp/terraform:${DOTFILE_VERSION}" .github/workflows/main.yml | wc -l | tr -d ' ')" != "$TERRAFORM_IMAGE_REFERENCES" ]
then
echo -e "\033[1;31mError: terraform version in .terraform-version file does not match docker://hashicorp/terraform versions in .github/workflows/main.yml"
exit 1
fi
- name: Run a Terraform init
uses: docker://hashicorp/terraform:1.10.3
with:
entrypoint: terraform
args: init
- name: Run a Terraform validate
uses: docker://hashicorp/terraform:1.10.3
with:
entrypoint: terraform
args: validate
- name: Run a Terraform format check
uses: docker://hashicorp/terraform:1.10.3
with:
entrypoint: terraform
args: fmt -check=true -diff=true
validate-terraform-docs:
name: Validate Terraform Docs
needs: validate-terraform
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
- name: Generate Terraform docs
uses: terraform-docs/[email protected]
with:
working-dir: .
config-file: .terraform-docs.yml
output-file: README.md
output-method: inject
fail-on-diff: true