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

fatal: not a git repository (or any parent up to mount point /github) #102

Open scott-doyland-burrows opened 1 year ago

scott-doyland-burrows commented 1 year ago

Please see the screenshot: image

I run a workflow, that calls a reusable workflow, that in turn calls a composite action, and in turn that composite calls the tf docs action. The tf docs action eventually gets run like this:

- name: Terraform docs
   if: github.event_name == 'pull_request'
   uses: terraform-docs/gh-actions@v1.0.0
   with:
     working-dir: ./terraform/terraform
     output-method: replace

My repo is checked out to a terraform directory, and in that I have a directory named terraform where the tf code is, like this:

- name: Checkout Code on PR
  if: |
  inputs.CodeCheckout == 'true' &&
  github.event_name == 'pull_request'
  uses: actions/checkout@v3
  with:
    path: terraform
    ref: ${{ github.event.pull_request.head.ref }}

I know the checkout is working OK as I can run terraform itself.

This is running on a ubuntu-latest github hosted runner.

I did some testing and can see the README.md is updated (ran a cat of the file from the github hosted runner after the failed tf docs action).

I have tried various settings for the tf docs action, such as find-dir, altering the working-dir (such as removing the ./ from the directory name), but it always fails with the same issue.

timothyclarke commented 5 days ago

I've encountered this one as well. My use case is having custom checkov rules in a different repo.

I believe the following in relation to this issue

I can see obvious issues with dual use of working-dir so perhaps a git-checkout-dir arg

The problem may also be https://github.com/terraform-docs/gh-actions/blob/main/src/docker-entrypoint.sh#L155 having no way to alter the GITHUB_WORKSPACE env var