Skip to content

ci(security): add gitleaks workflow + docs-only skip + sw-ci toggle #1

ci(security): add gitleaks workflow + docs-only skip + sw-ci toggle

ci(security): add gitleaks workflow + docs-only skip + sw-ci toggle #1

Workflow file for this run

name: Security
on:
pull_request:
push:
branches: [main, master]
permissions:
contents: read
jobs:
gitleaks:
name: gitleaks (secrets scan)
runs-on: ${{ vars.USE_SELF_HOSTED == 'false' && 'ubuntu-latest' || fromJSON('["self-hosted","sw-ci"]') }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check if docs-only change (skip scan, still report)
id: scope
shell: bash
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
git fetch origin "${{ github.base_ref }}" --depth=1 2>/dev/null || true
changed=$(git diff --name-only "origin/${{ github.base_ref }}...HEAD" 2>/dev/null || echo "")
else
changed=$(git diff --name-only HEAD~1 HEAD 2>/dev/null || echo "")
fi
if [ -z "$changed" ]; then
echo "no diff detected — running scan to be safe"
echo "scan=true" >> "$GITHUB_OUTPUT"
exit 0
fi
non_docs=$(echo "$changed" | grep -v -E '\.md$|^docs/|^CHANGELOG' || true)
if [ -z "$non_docs" ]; then
echo "docs-only change — skipping scan"
echo "scan=false" >> "$GITHUB_OUTPUT"
else
echo "non-docs change present — running scan"
echo "scan=true" >> "$GITHUB_OUTPUT"
fi
- name: Run gitleaks
if: steps.scope.outputs.scan == 'true'
uses: gitleaks/gitleaks-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Skipped (docs-only)
if: steps.scope.outputs.scan != 'true'
run: echo "skipped — docs-only PR"