Skip to content

Commit 98c3ac6

Browse files
committed
ci: add Gitleaks secret scanning job to CI pipeline with job summary
- Add gitleaks job to ci.yml that runs on every PR and push to main - Fetches full git history (fetch-depth: 0) for complete scan coverage - CI fails if any secrets are detected - Writes pass/fail summary to GitHub Actions job summary - Uploads gitleaks-report.json artifact on failure for review - .gitleaks.toml already committed with allowlist rules for false positives - Add gitleaks to all-tests gate so secret scan must pass before merge Closes Vacci-chain#333 Closes Vacci-chain#334
1 parent a062f85 commit 98c3ac6

1 file changed

Lines changed: 44 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,53 @@ jobs:
186186
all-tests:
187187
name: All tests passed
188188
runs-on: ubuntu-latest
189-
needs: [contract, backend, frontend, python]
189+
needs: [contract, backend, frontend, python, gitleaks]
190190
steps:
191191
- run: echo "All test jobs passed."
192192

193+
gitleaks:
194+
name: Secret scanning (Gitleaks)
195+
runs-on: ubuntu-latest
196+
steps:
197+
- uses: actions/checkout@v4
198+
with:
199+
fetch-depth: 0
200+
201+
- name: Run Gitleaks
202+
id: gitleaks
203+
uses: gitleaks/gitleaks-action@v2
204+
env:
205+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
206+
continue-on-error: true
207+
208+
- name: Write job summary
209+
if: always()
210+
run: |
211+
if [ "${{ steps.gitleaks.outcome }}" = "success" ]; then
212+
echo "## ✅ Gitleaks Secret Scan" >> $GITHUB_STEP_SUMMARY
213+
echo "No secrets detected." >> $GITHUB_STEP_SUMMARY
214+
else
215+
echo "## ❌ Gitleaks Secret Scan — Secrets Detected" >> $GITHUB_STEP_SUMMARY
216+
echo "Gitleaks found potential secrets in this commit. Review the report artifact." >> $GITHUB_STEP_SUMMARY
217+
if [ -f gitleaks-report.json ]; then
218+
echo '```json' >> $GITHUB_STEP_SUMMARY
219+
cat gitleaks-report.json >> $GITHUB_STEP_SUMMARY
220+
echo '```' >> $GITHUB_STEP_SUMMARY
221+
fi
222+
fi
223+
224+
- name: Upload Gitleaks report
225+
if: failure()
226+
uses: actions/upload-artifact@v4
227+
with:
228+
name: gitleaks-report
229+
path: gitleaks-report.json
230+
retention-days: 30
231+
232+
- name: Fail if secrets detected
233+
if: steps.gitleaks.outcome == 'failure'
234+
run: exit 1
235+
193236
docker:
194237
name: Docker build validation
195238
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)