Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/secret-scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Secret Scanning

on:
pull_request:
push:
branches: [main, master]

permissions:
contents: read

jobs:
secret-scan:
name: Gitleaks Secret Scan
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install Gitleaks
run: |
VERSION=$(curl -sI https://github.com/gitleaks/gitleaks/releases/latest | grep -i '^location:' | sed 's/.*tag\/v//' | tr -d '\r')
curl -sSfL "https://github.com/gitleaks/gitleaks/releases/download/v${VERSION}/gitleaks_${VERSION}_linux_x64.tar.gz" | tar xz
chmod +x gitleaks

- name: Scan for secrets
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
./gitleaks detect --source . --log-opts "${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}" --verbose
else
BEFORE="${{ github.event.before }}"
if [ "$BEFORE" = "0000000000000000000000000000000000000000" ]; then
# Branch creation push -- no prior SHA. Scan full tree.
./gitleaks detect --source . --verbose
else
./gitleaks detect --source . --log-opts "${BEFORE}..${{ github.sha }}" --verbose
fi
fi
Loading