Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intended usage for mono repo. #70

Open
joeypiccola opened this issue Nov 2, 2021 · 3 comments
Open

Intended usage for mono repo. #70

joeypiccola opened this issue Nov 2, 2021 · 3 comments

Comments

@joeypiccola
Copy link

joeypiccola commented Nov 2, 2021

I have a single repo with a modules directory. Each directory in modules is a unique and standalone module. How would I configure the GH action to generate a readme.md in the root of each module directory? Thanks for the usage help.

git_repos/az-modules/ 
➜ tree                 
.
├── .github
│   └── workflows
│       └── documentation.yml
├── readme.md
└── modules
    ├── aks
    │   ├── main.tf
    │   ├── outputs.tf
    │   ├── variables.tf
    │   └── versions.tf
    ├── application_insights
    │   ├── main.tf
    │   ├── output.tf
    │   ├── variables.tf
    │   └── versions.tf
    ├── azuread_application
    │   ├── main.tf
    │   ├── output.tf
    │   ├── variables.tf
    │   └── versions.tf
@joeypiccola
Copy link
Author

joeypiccola commented Nov 4, 2021

Using the following .terraform-docs.yml I can achieve what I want when manually calling terraform-docs outside of CI. Works great.

# .terraform-docs.yml

formatter: "markdown"

output:
  file: "readme.md"
  mode: inject

recursive:
  enabled: true
  path: modules

header-from: main.tf

content: |-

  {{ .Header }}

  {{ .Inputs }}

  {{ .Outputs }}

sort:
  enabled: true
  by: required

settings:
  anchor: false
  html: false
  escape: false
  hide-empty: true

However, I can't seem to duplicate the recursion piece of it when run in CI. My current documentation.yml is below. This updates the readme.md in the root directory only. FWIW, when I remove output.file from .terraform-docs.yml I get errors in the GitHub action saying '--output-file' cannot be empty with '--recursive', which suggest the recursive key in .terraform-docs.yml is being read. Thanks for the help.

# documentation.yml

name: Generate terraform docs
on:
  - pull_request

jobs:
  docs:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
      with:
        ref: ${{ github.event.pull_request.head.ref }}

    - name: Render terraform docs and push changes back to PR
      uses: terraform-docs/gh-actions@main
      with:
        git-push: true
        working-dir: .
        config-file: .terraform-docs.yml
        output-method: inject
        output-file: readme.md

@evdokimovn
Copy link

You can do this now from master branch
b70f26c

@oliveirafilipe
Copy link

Is it close? I think it is, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants