@@ -43,10 +43,14 @@ jobs:
4343 fetch-depth : 1
4444 persist-credentials : true
4545
46- - name : Fetch base and head commits
46+ - name : Fetch base and head commits (pull_request)
4747 if : github.event_name == 'pull_request'
4848 run : git fetch --depth=1 origin ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }}
4949
50+ - name : Fetch base and head commits (merge_group)
51+ if : github.event_name == 'merge_group'
52+ run : git fetch --depth=1 origin ${{ github.event.merge_group.base_sha }} ${{ github.event.merge_group.head_sha }}
53+
5054 - name : Remove persisted credentials
5155 run : git config --unset-all http.https://github.com/.extraheader
5256
@@ -97,10 +101,15 @@ jobs:
97101 set +e
98102 echo "[]" > results.json
99103
100- if [[ "${{ github.event_name }}" == "pull_request" ]]; then
101- # PR: Scan only changed files (using two-dot diff with explicit base SHA)
102- echo "Scanning changed files in PR..."
103- git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} > changed-files.txt
104+ if [[ "${{ github.event_name }}" == "pull_request" ]] || [[ "${{ github.event_name }}" == "merge_group" ]]; then
105+ # PR / merge queue: scan only paths that differ from base..head (not the entire checkout)
106+ if [[ "${{ github.event_name }}" == "pull_request" ]]; then
107+ echo "Scanning changed files in PR..."
108+ git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} > changed-files.txt
109+ else
110+ echo "Scanning changed files in merge group..."
111+ git diff --name-only ${{ github.event.merge_group.base_sha }} ${{ github.event.merge_group.head_sha }} > changed-files.txt
112+ fi
104113
105114 if [[ -s changed-files.txt ]]; then
106115 while IFS= read -r file; do
@@ -124,7 +133,7 @@ jobs:
124133 echo "No files changed"
125134 fi
126135 else
127- # Push to main: Scan current filesystem
136+ # push to main (and any other events): full filesystem scan
128137 echo "Scanning current filesystem..."
129138 trufflehog filesystem . --exclude-paths /tmp/trufflehog-exclude.txt --concurrency 16 --json --no-update --results=verified,unverified > results.ndjson || true
130139 fi
0 commit comments