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

Add support for multiple directories #25

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 9 additions & 5 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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}"
Expand All @@ -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.
Expand Down