Skip to content

Commit 14151cc

Browse files
fix: ensure results.json is always included in trufflehog artifacts
- Improved error handling for artifact preparation - Ensures results.json is always present in uploaded artifacts - Added clearer logging to show which files are copied - Creates empty results.json if scan produces no results
1 parent 479b6ce commit 14151cc

1 file changed

Lines changed: 21 additions & 5 deletions

File tree

.github/workflows/reusable-trufflehog.yml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,14 +216,30 @@ jobs:
216216
echo "[]" > results.json
217217
echo "Created empty results.json"
218218
fi
219-
219+
220220
# Create artifacts directory and copy files
221221
mkdir -p trufflehog-artifacts
222-
cp trufflehog_scan.txt trufflehog-artifacts/ 2>/dev/null || echo "trufflehog_scan.txt not found"
223-
cp results.json trufflehog-artifacts/ 2>/dev/null || echo "results.json not found"
224-
222+
223+
# Copy text report
224+
if [[ -f "trufflehog_scan.txt" ]]; then
225+
cp trufflehog_scan.txt trufflehog-artifacts/
226+
echo "✓ Copied trufflehog_scan.txt"
227+
else
228+
echo "⚠ trufflehog_scan.txt not found"
229+
fi
230+
231+
# Copy JSON results
232+
if [[ -f "results.json" ]]; then
233+
cp results.json trufflehog-artifacts/
234+
echo "✓ Copied results.json"
235+
else
236+
echo "⚠ results.json not found, creating empty one"
237+
echo "[]" > trufflehog-artifacts/results.json
238+
fi
239+
240+
echo ""
225241
echo "Files in artifacts directory:"
226-
ls -la trufflehog-artifacts/
242+
ls -lah trufflehog-artifacts/
227243
228244
- name: Upload scan results
229245
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0

0 commit comments

Comments
 (0)