diff --git a/README.md b/README.md index ce3b5be..52bb80a 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ The action requires the https://github.com/actions/checkout before to download t ## Inputs * `tfsec_actions_comment` - (Optional) Whether or not to comment on GitHub pull requests. Defaults to `true`. -* `tfsec_actions_working_dir` - (Optional) Terraform working directory location. Defaults to `'.'`. +* `tfsec_actions_working_dir` - (Optional) Terraform working directory location. Multiple folders allowed, separated by spaces. Defaults to `'.'`. * `tfsec_exclude` - (Optional) Provide checks via `,` without space to exclude from run. No default * `tfsec_version` - (Optional) Specify the version of tfsec to install. Defaults to the latest diff --git a/entrypoint.sh b/entrypoint.sh index 8cb3ec4..0fade7d 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,12 +1,14 @@ #!/bin/bash -# Comment on the pull request if necessary. +# Add specific directory if any if [ "${INPUT_TFSEC_ACTIONS_WORKING_DIR}" != "" ] && [ "${INPUT_TFSEC_ACTIONS_WORKING_DIR}" != "." ]; then - TFSEC_WORKING_DIR="/github/workspace/${INPUT_TFSEC_ACTIONS_WORKING_DIR}" + TFSEC_WORKING_DIR="${INPUT_TFSEC_ACTIONS_WORKING_DIR}" else - TFSEC_WORKING_DIR="/github/workspace/" + TFSEC_WORKING_DIR="." fi +echo "$TFSEC_WORKING_DIR" + # grab tfsec from GitHub (taken from README.md) if [[ -n "$INPUT_TFSEC_VERSION" ]]; then env GO111MODULE=on go get -u github.com/tfsec/tfsec/cmd/tfsec@"${INPUT_TFSEC_VERSION}" @@ -15,10 +17,12 @@ else fi if [[ -n "$INPUT_TFSEC_EXCLUDE" ]]; then - TFSEC_OUTPUT=$(/go/bin/tfsec ${TFSEC_WORKING_DIR} --no-colour -e "${INPUT_TFSEC_EXCLUDE}") + TFSEC_CMD="/go/bin/tfsec ${TFSEC_WORKING_DIR} --no-colour -e \"${INPUT_TFSEC_EXCLUDE}\"" else - TFSEC_OUTPUT=$(/go/bin/tfsec ${TFSEC_WORKING_DIR} --no-colour) + TFSEC_CMD="/go/bin/tfsec ${TFSEC_WORKING_DIR} --no-colour" fi +echo "$TFSEC_CMD" +TFSEC_OUTPUT=$($TFSEC_CMD) TFSEC_EXITCODE=${?} # Exit code of 0 indicates success.