Skip to content

Commit

Permalink
Add recursive and recursive path to action
Browse files Browse the repository at this point in the history
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
  • Loading branch information
khos2ow committed Nov 24, 2021
1 parent 626e545 commit 49116c9
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ jobs:
with:
find-dir: examples/tf12_find

- name: Should generate README.md for tf12_find and its submodules recursively
uses: ./
with:
working-dir: examples/tf12_find
recursive: true
recursive-path: modules

- name: Should generate README.md for tf12_config
uses: ./
with:
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ jobs:
| output-file | File in module directory where the docs should be placed | `USAGE.md` | false |
| output-format | terraform-docs format to generate content (see [all formats](https://github.com/terraform-docs/terraform-docs/blob/master/docs/FORMATS\_GUIDE.md)) (ignored if `config-file` is set) | `markdown table` | false |
| output-method | Method should be one of `replace`, `inject`, or `print` | `inject` | false |
| recursive | If true it will update submodules recursively | `false` | false |
| recursive-path | Submodules path to recursively update | `modules` | false |
| template | When provided will be used as the template if/when the `output-file` does not exist | `<!-- BEGIN_TF_DOCS -->\n{{ .Content }}\n<!-- END_TF_DOCS -->` | false |
| working-dir | Comma separated list of directories to generate docs for (ignored if `atlantis-file` or `find-dir` is set) | `.` | false |

Expand Down
10 changes: 10 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ inputs:
description: Name of root directory to extract list of directories by running `find ./find_dir -name *.tf` (ignored if `atlantis-file` is set)
required: false
default: "disabled"
recursive:
description: If true it will update submodules recursively
required: false
default: "false"
recursive-path:
description: Submodules path to recursively update
required: false
default: "modules"
output-format:
description: terraform-docs format to generate content (see [all formats](https://github.com/terraform-docs/terraform-docs/blob/master/docs/FORMATS_GUIDE.md)) (ignored if `config-file` is set)
required: false
Expand Down Expand Up @@ -82,6 +90,8 @@ runs:
INPUT_WORKING_DIR: ${{ inputs.working-dir }}
INPUT_ATLANTIS_FILE: ${{ inputs.atlantis-file }}
INPUT_FIND_DIR: ${{ inputs.find-dir }}
INPUT_RECURSIVE: ${{ inputs.recursive }}
INPUT_RECURSIVE_PATH: ${{ inputs.recursive-path }}
INPUT_OUTPUT_FORMAT: ${{ inputs.output-format }}
INPUT_OUTPUT_METHOD: ${{ inputs.output-method }}
INPUT_OUTPUT_FILE: ${{ inputs.output-file }}
Expand Down
7 changes: 7 additions & 0 deletions src/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ update_doc() {
exec_args+=(--output-template "${INPUT_TEMPLATE}")
fi

if [ "${INPUT_RECURSIVE}" = "true" ]; then
if [ -n "${INPUT_RECURSIVE_PATH}" ]; then
exec_args+=(--recursive)
exec_args+=(--recursive-path "${INPUT_RECURSIVE_PATH}")
fi
fi

exec_args+=("${working_dir}")

local success
Expand Down

0 comments on commit 49116c9

Please sign in to comment.