terraform-docs / gh-actions

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

TF Docs adds extra files on git_add when using working directory '.' #85

Open Penson122 opened 2 years ago

Penson122 commented 2 years ago

Description of your changes

When using TF Docs after other steps which contain lint actions for example which output additional files to the current working directory TF Docs will add those files. With the following configuration at the end of a workflow run I get additional files in my PRs. I believe this is because the OUTPUT_FILE variable is not defined. It appears it should be $INPUT_OUTPUT_FILE.

To replicate, create a job which touchs some files and then runs this step.

    - name: TF-Docs
      uses: terraform-docs/gh-actions@v1.0.0
      with:
        working-dir: .
        output-file: README.md
        output-method: inject
        git-push: "true"

See example issue here:

https://github.com/Penson122/test-tf-docs/pull/1/commits/f67b1e8580903e33a032306ccfa29a06329dc679

I have:

How has this code been tested

See this PR targeting my fork branch test-fix. Of note I have had to make two additional changes on that branch to get a passing build. The first commit uses the local docker image. This is so that I'm actually testing my branch and not the 1.0.0 published version. And secondly I've also had to amend the src/entrypoint.sh to resolve a workspace permissions issue. I'm not sure if this is something that will also need to be done if this change is to be released. I'll leave that for the maintainers to test, or otherwise please provide instructions.

https://github.com/Penson122/test-tf-docs/pull/2/commits/18296f0b5ce2070c2d6d82bd8b585d8c70f6b3a5

Also testing branch with additional commit to src/entrypoint.sh https://github.com/Penson122/gh-actions/commits/test-fix

mohamed-haidara-cko commented 2 years ago

Same issue for me as well. Is there any change to review and merge this?

mohamed-haidara-cko commented 1 year ago

Up (just in case the PR got forgotten) :-)

chelsea-codes commented 9 months ago

This would be a great fix to add. Is there anyone to review it? Thank you!