Skip to content

Find, verify, and analyze leaked credentials

Make the github action work with a path as input (#2908)

Ben Bridtsf122b295bf4d
diff --git a/action.yml b/action.yml
index 544877ca0..da93288a6 100644
--- a/action.yml
+++ b/action.yml
@@ -30,8 +30,8 @@ runs:
using: "composite"
steps:
- shell: bash
+ working-directory: ${{ inputs.path }}
env:
- REPO_PATH: ${{ inputs.path }}
BASE: ${{ inputs.base }}
HEAD: ${{ inputs.head }}
ARGS: ${{ inputs.extra_args }}
@@ -43,6 +43,7 @@ runs:
## Scan by BASE & HEAD user inputs ##
## If BASE == HEAD, exit with error ##
##########################################
+ git status >/dev/null # make sure we are in a git repostiory
if [ -n "$BASE" ] || [ -n "$HEAD" ]; then
if [ -n "$BASE" ]; then
base_commit=$(git rev-parse "$BASE" 2>/dev/null) || true
@@ -54,7 +55,7 @@ runs:
else
head_commit=""
fi
- if [ $base_commit == $head_commit ] ; then
+ if [ "$base_commit" == "$head_commit" ] ; then
echo "::error::BASE and HEAD commits are the same. TruffleHog won't scan anything. Please see documentation (https://github.com/trufflesecurity/trufflehog#octocat-trufflehog-github-action)."
exit 1
fi
@@ -85,7 +86,7 @@ runs:
##########################################
## Run TruffleHog ##
##########################################
- docker run --rm -v "$REPO_PATH":/tmp -w /tmp \
+ docker run --rm -v .:/tmp -w /tmp \
ghcr.io/trufflesecurity/trufflehog:${VERSION} \
git file:///tmp/ \
--since-commit \