terraform-docs / gh-actions

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

terraform-docs output differs when running as github action and in cli #91

Closed tobiasehlert closed 2 years ago

tobiasehlert commented 2 years ago

Describe the bug

I have noticed a difference when it comes to the README output when using the GitHub Action terraform-docs/gh-actions app and by running the same command in the cli on my computer.

Terraform version provider information:

terraform {
  required_providers {
    helm = {
      source  = "hashicorp/helm"
      version = "~> 2.5.1"
    }
  }
}

Terraform lock file information:

provider "registry.terraform.io/hashicorp/helm" {
  version     = "2.5.1"
  constraints = "~> 2.5.1"
  hashes = [<truncated>]
}

The output that is different from each other is in the Provider markdown section.

Output when running in GitHub Action step:

## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_helm"></a> [helm](#requirement\_helm) | ~> 2.5.1 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_helm"></a> [helm](#provider\_helm) | ~> 2.5.1 |

Output when running in cli:

## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_helm"></a> [helm](#requirement\_helm) | ~> 2.5.1 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_helm"></a> [helm](#provider\_helm) | 2.5.1 |

How can we reproduce it?

Step in GitHub Action workflow:

- name: Running Terraform docs
  uses: terraform-docs/gh-actions@main
  with:
    recursive: true

cli command to run similar to workflow:

terraform-docs markdown table --output-file README.md --recursive .

Environment information

terraform-docs in GitHub Action:

terraform-docs in cli:

tobiasehlert commented 2 years ago

Found the reason for the output to be different from each other..

The lock files are not checked in the repository, which is the reason for the GitHub Action step to not be able to find the correct version as specified in the lock file.