11name : Terraform Docs
22
33on :
4- push :
5- branches :
6- - main
7- - master
8- pull_request :
9- branches :
10- - main
11- - master
4+ workflow_call :
125
136env :
147 TERRAFORM_DOCS_VERSION : v0.18.0
@@ -20,18 +13,65 @@ jobs:
2013 - name : Checkout repository
2114 uses : actions/checkout@v4
2215 with :
23- ref : ${{ github.event.pull_request.head. ref }}
16+ ref : ${{ github.ref }}
2417
25- - name : Render and Push terraform docs for main and modules
18+ - name : Render and Push terraform docs for main module
2619 uses : terraform-docs/gh-actions@main
2720 with :
2821 working-dir : .
2922 git-push : true
30- config-file : .terraform-docs.yaml
23+ output-file : README.md
24+ output-format : markdown table
25+ output-method : replace
26+ recursive : false
27+ template : |
28+ <!-- BEGIN_TF_DOCS -->
29+ {{ .Content }}
30+ <!-- END_TF_DOCS -->
31+ {{- printf "\n" -}}
32+ args : " --header-from .header.md"
33+
34+ - name : Check if modules folder exists
35+ id : check_modules
36+ run : echo "modules_exists=$(if [ -d modules ]; then echo true; else echo false; fi)" >> $GITHUB_ENV
37+
38+ - name : Render and Push terraform docs for sub modules
39+ if : env.modules_exists == 'true'
40+ uses : terraform-docs/gh-actions@main
41+ with :
42+ working-dir : .
43+ git-push : true
44+ output-file : README.md
45+ output-format : markdown table
46+ output-method : replace
47+ recursive : true
48+ recursive-path : modules
49+ template : |
50+ <!-- BEGIN_TF_DOCS -->
51+ {{ .Content }}
52+ <!-- END_TF_DOCS -->
53+ {{- printf "\n" -}}
54+ args : " --header-from .header.md"
55+
56+
57+ - name : Check if examples folder exists
58+ id : check_examples
59+ run : echo "examples_exists=$(if [ -d examples ]; then echo true; else echo false; fi)" >> $GITHUB_ENV
3160
3261 - name : Render and Push terraform docs for examples
62+ if : env.examples_exists == 'true'
3363 uses : terraform-docs/gh-actions@main
3464 with :
3565 working-dir : .
3666 git-push : true
37- config-file : .terraform-docs-example.yaml
67+ output-file : README.md
68+ output-format : markdown table
69+ output-method : replace
70+ recursive : true
71+ recursive-path : examples
72+ template : |
73+ <!-- BEGIN_TF_DOCS -->
74+ {{ .Content }}
75+ <!-- END_TF_DOCS -->
76+ {{- printf "\n" -}}
77+ args : " --header-from .header.md"
0 commit comments