From 741597408f0374c81ed4f535f23cb34f7e129475 Mon Sep 17 00:00:00 2001 From: Bostjan Bozic Date: Thu, 24 Aug 2023 14:26:55 +0200 Subject: [PATCH 1/2] Set git add paths to git ls-files -m output Signed-off-by: Bostjan Bozic --- src/docker-entrypoint.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/docker-entrypoint.sh b/src/docker-entrypoint.sh index b90445b..4a9c5d2 100755 --- a/src/docker-entrypoint.sh +++ b/src/docker-entrypoint.sh @@ -147,7 +147,9 @@ update_doc() { fi if [ "${INPUT_OUTPUT_METHOD}" == "inject" ] || [ "${INPUT_OUTPUT_METHOD}" == "replace" ]; then - git_add "${working_dir}/${OUTPUT_FILE}" + for modified_files in $(git ls-files -m | grep -i $(echo ${INPUT_OUTPUT_FILE} | cut -d'/' -f2- )); do + git_add "${modified_files}" + done fi } From b3ba6510d1ddb80c9c06f6686534cedace91b6b3 Mon Sep 17 00:00:00 2001 From: Bostjan Bozic Date: Thu, 24 Aug 2023 14:41:12 +0200 Subject: [PATCH 2/2] Update README and fix entry script for shellcheck Signed-off-by: Bostjan Bozic --- README.md | 4 ++-- src/docker-entrypoint.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index bbe3fe3..a592f0a 100644 --- a/README.md +++ b/README.md @@ -75,10 +75,10 @@ jobs: | indention | Indention level of Markdown sections [1, 2, 3, 4, 5] | `2` | false | | output-file | File in module directory where the docs should be placed | `README.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 | +| output-method | Method should be one of `replace`, `inject`, or `print`. Set as an empty string if `output.mode` and `output.file` are defined in config-file | `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 | `\n{{ .Content }}\n` | false | +| template | When provided will be used as the template if/when the `output-file` does not exist. Set as an empty string if `output.template` is defined in config-file | `\n{{ .Content }}\n` | false | | working-dir | Comma separated list of directories to generate docs for (ignored if `atlantis-file` or `find-dir` is set) | `.` | false | #### Output Method (output-method) diff --git a/src/docker-entrypoint.sh b/src/docker-entrypoint.sh index 4a9c5d2..25431c7 100755 --- a/src/docker-entrypoint.sh +++ b/src/docker-entrypoint.sh @@ -147,7 +147,7 @@ update_doc() { fi if [ "${INPUT_OUTPUT_METHOD}" == "inject" ] || [ "${INPUT_OUTPUT_METHOD}" == "replace" ]; then - for modified_files in $(git ls-files -m | grep -i $(echo ${INPUT_OUTPUT_FILE} | cut -d'/' -f2- )); do + for modified_files in $(git ls-files -m | grep -i "$(echo "${INPUT_OUTPUT_FILE}" | cut -d'/' -f2- )"); do git_add "${modified_files}" done fi @@ -179,7 +179,7 @@ fi set +e num_changed=$(git_status) set -e -echo "num_changed=${num_changed}" >> $GITHUB_OUTPUT +echo "num_changed=${num_changed}" >> "$GITHUB_OUTPUT" if [ "${INPUT_GIT_PUSH}" = "true" ]; then git_commit