Skip to content

Commit 81c7022

Browse files
authored
Add terraform docs generation (#92)
1 parent a2ee235 commit 81c7022

File tree

5 files changed

+119
-9
lines changed

5 files changed

+119
-9
lines changed

.githooks/pre-commit

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ if command_exists typos; then
3434
echo "$files" | xargs typos
3535
fi
3636

37+
if command_exists terraform-docs; then
38+
pushd asset-account/terraform/stack-set
39+
files="$files asset-account/terraform/stack-set/README.md"
40+
41+
terraform-docs markdown . --output-file README.md
42+
popd
43+
fi
44+
3745
if command_exists ./node_modules/.bin/prettier; then
3846
echo "$files" | xargs ./node_modules/.bin/prettier --ignore-unknown --write
3947
fi

.github/workflows/ci.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,44 @@ jobs:
4747
- run: terraform validate
4848
working-directory: ${{ matrix.project }}
4949

50+
terraform-docs:
51+
runs-on: ubuntu-latest
52+
53+
strategy:
54+
matrix:
55+
terraform_module:
56+
- asset-account/terraform/stack-set
57+
58+
steps:
59+
- uses: actions/checkout@v4
60+
- uses: actions/setup-node@v4
61+
with:
62+
node-version: "22"
63+
cache: "npm"
64+
- run: npm ci --ignore-scripts
65+
66+
- run: |
67+
curl https://github.com/terraform-docs/terraform-docs/releases/download/v0.19.0/terraform-docs-v0.19.0-linux-amd64.tar.gz \
68+
--location \
69+
--silent \
70+
--retry 5 \
71+
--retry-all-errors \
72+
--show-error \
73+
| tar -xz terraform-docs > ./terraform-docs
74+
working-directory: ${{ matrix.terraform_module }}
75+
76+
- run: chmod +x ./terraform-docs
77+
working-directory: ${{ matrix.terraform_module }}
78+
79+
- run: ./terraform-docs markdown . --output-file README.md
80+
working-directory: ${{ matrix.terraform_module }}
81+
82+
- run: npx prettier -w .
83+
84+
- run: >-
85+
git diff --exit-code --color=always || ( echo "Terraform docs are
86+
out-of-date. See the diff above." && exit 1 )
87+
5088
prettier:
5189
runs-on: ubuntu-latest
5290
steps:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
terraform.tfstate
44
terraform.tfstate.backup
55
terraform.tfvars
6+
/node_modules

0 commit comments

Comments
 (0)