terraform-docs / gh-actions

A Github action for generating Terraform module documentation using terraform-docs and gomplate
Apache License 2.0
144 stars 61 forks source link

Update readme.md in root folder from terraform files in subfolders not working #93

Open cberge908 opened 1 year ago

cberge908 commented 1 year ago

Describe the bug

It seems that the following is not working with the github action for terraform-docs. I have the following directory structure, terraform files in a subdirectory and the readme.md to update in the root folder:

.
├── application
│   ├── main.tf
│   ├── terraform.tfvars
│   └── variables.tf
├── argoCD
│   ├── kustomization.yaml
│   ├── patch_argocd-cm.yaml
│   └── patch_clusterrolebinding.yaml
├── infrastructure
│   ├── main.tf
│   ├── terraform.tfvars
│   └── variables.tf
└── readme.md

When setting the working-directory to infrastructure and the output file to ../readme the changes will be made but not committed during the execution of the action. Output from the log looks like this:

::debug working_dir=infrastructure
::debug output_mode=inject
::debug output_file=../readme.md
::debug terraform-docs markdown table --hide data-sources --hide footer --hide header --hide inputs --hide outputs --hide providers --hide requirements --hide resources --indent 2 --output-mode inject --output-file ../readme.md --output-template <!-- BEGIN_TF_DOCS -->
{{ .Content }}
<!-- END_TF_DOCS --> infrastructure
readme.md updated successfully
::debug No change in infrastructure/ detected
::debug Following files will be committed
 M readme.md
On branch fix-tf-docs-section
Your branch is up to date with 'origin/fix-tf-docs-section'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
    modified:   readme.md

no changes added to commit (use "git add" and/or "git commit -a")

Technically it should work, but I feel that there is an error in the logic which files should be added to the commit.

How can we reproduce it?

Use a git repository with the terraform file in a subfolder of the root folder. Writing the terraform-docs changes into a file readme.md in the root directory via the github action. See folder structure above.

Environment information

Terraform-docs github action v1.0.0

Raghunadh89 commented 1 year ago

Thanks for raising the bug, I am facing the same issue

Lincon-Freitas commented 1 year ago

I am also facing the same issue

SamuelMolling commented 1 year ago

Same problem here

xiujiao commented 6 months ago

I have encountered similar issue. The difference is I configured find-dir to specify sub dir that I want it generate README.me, but it always modify README.md in root dir regardless. When there are new README generated for sub dir it works; when only README in root get modified, the above issue show up

xiujiao commented 6 months ago

Any plan to address this issue in your roadmap?