Skip to content

secrets-scan

secrets-scan #28

Workflow file for this run

name: secrets-scan
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
schedule:
# Weekly scan
- cron: '0 0 * * 0'
workflow_dispatch:
permissions:
contents: read
security-events: write
actions: read
jobs:
gitleaks:
name: Scan for secrets
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
# Fetch all history for accurate results
fetch-depth: 0
- name: Run Gitleaks
uses: zricethezav/gitleaks-action@v2
continue-on-error: true
with:
# Use default configuration
config-path: ""
# Generate SARIF report
report-format: sarif
report-path: gitleaks-report.sarif
# Show more detailed output
verbose: true
# Check the full git history
fetch-depth: 0
# Additional paths to scan (optional)
paths: ".,.github/workflows/"
- name: Fail if secrets were found
if: failure()
run: |
echo "🚨 Gitleaks detected secrets. Failing the build."
exit 1
- name: Upload SARIF to Code Scanning
if: always() && hashFiles('gitleaks-report.sarif') != ''
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: gitleaks-report.sarif
- name: Archive SARIF for debugging
if: always() && hashFiles('gitleaks-report.sarif') != ''
uses: actions/upload-artifact@v4
with:
name: gitleaks-report
path: gitleaks-report.sarif