Skip to content

Commit

Permalink
Merge pull request #1 from ucraft-com/terraform
Browse files Browse the repository at this point in the history
add terraform-docs tool in pre-commit
  • Loading branch information
devops-mher authored Apr 29, 2022
2 parents e43f9c9 + 56ebe1d commit 11400cd
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

echo "Start git pre-commit hooks";

echo "Start terraform docs";
for i in `ls -d */`;do
if ! git diff --cached --quiet "${i}"
then
echo "Generating doc file: ${i}";
terraform-docs markdown table --output-file README.md --output-mode inject "${i}";
fi
done
echo "End terraform docs";

echo "Start terraform fmt";
for y in $(find . -name '*.tf' -print)
do
if ! git diff --cached --quiet "${y}"
then
echo "Formatting the file: ${y}";
terraform fmt -write=true "${y}"
fi
done
echo "End terraform fmt";

echo "End git pre-commit hooks";

0 comments on commit 11400cd

Please sign in to comment.