-
Notifications
You must be signed in to change notification settings - Fork 1
/
entrypoint.sh
executable file
·39 lines (34 loc) · 1.42 KB
/
entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
INPUT_CONFIG_PATH="$1"
CONFIG=""
# check if a custom config have been provided
if [ -f "$GITHUB_WORKSPACE/$INPUT_CONFIG_PATH" ]; then
CONFIG=" --config-path=$GITHUB_WORKSPACE/$INPUT_CONFIG_PATH"
fi
echo running gitleaks "$(gitleaks --version) with the following command👇"
if [ "$GITHUB_EVENT_NAME" = "push" ]
then
echo gitleaks --path=$GITHUB_WORKSPACE --verbose --redact $CONFIG
CAPTURE_OUTPUT=$(gitleaks --path=$GITHUB_WORKSPACE --verbose --redact $CONFIG)
elif [ "$GITHUB_EVENT_NAME" = "pull_request" ]
then
git --git-dir="$GITHUB_WORKSPACE/.git" log --left-right --cherry-pick --pretty=format:"%H" remotes/origin/$GITHUB_BASE_REF... > commit_list.txt
echo gitleaks --path=$GITHUB_WORKSPACE --verbose --redact --commits-file=commit_list.txt $CONFIG
CAPTURE_OUTPUT=$(gitleaks --path=$GITHUB_WORKSPACE --verbose --redact --commits-file=commit_list.txt $CONFIG)
fi
if [ $? -eq 1 ]
then
GITLEAKS_RESULT=$(echo -e "\e[31m🛑 STOP! Gitleaks encountered leaks")
echo "$GITLEAKS_RESULT"
echo "::set-output name=exitcode::$GITLEAKS_RESULT"
echo "----------------------------------"
echo "$CAPTURE_OUTPUT"
echo "::set-output name=result::$CAPTURE_OUTPUT"
echo "----------------------------------"
exit 1
else
GITLEAKS_RESULT=$(echo -e "\e[32m✅ SUCCESS! Your code is good to go!")
echo "$GITLEAKS_RESULT"
echo "::set-output name=exitcode::$GITLEAKS_RESULT"
echo "------------------------------------"
fi