File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Secret Scan
2+
3+ on :
4+ pull_request :
5+ branches :
6+ - main
7+ - staging
8+ push :
9+ branches :
10+ - main
11+ - staging
12+ workflow_dispatch :
13+ schedule :
14+ - cron : " 17 3 * * *"
15+
16+ permissions :
17+ contents : read
18+
19+ concurrency :
20+ group : ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
21+ cancel-in-progress : true
22+
23+ jobs :
24+ gitleaks :
25+ name : Gitleaks
26+ runs-on : ubuntu-latest
27+ timeout-minutes : 10
28+
29+ steps :
30+ - name : Checkout code
31+ uses : actions/checkout@v6
32+ with :
33+ fetch-depth : 0
34+ persist-credentials : false
35+
36+ - name : Install gitleaks
37+ shell : bash
38+ run : |
39+ set -euo pipefail
40+ version="8.30.1"
41+ archive="gitleaks_${version}_linux_x64.tar.gz"
42+ curl --fail --location --silent --show-error \
43+ --output "${archive}" \
44+ "https://github.com/gitleaks/gitleaks/releases/download/v${version}/${archive}"
45+ tar -xzf "${archive}" gitleaks
46+ install -m 0755 gitleaks /usr/local/bin/gitleaks
47+ gitleaks version
48+
49+ - name : Scan current tree
50+ shell : bash
51+ run : |
52+ set -euo pipefail
53+ mkdir -p secret-scan-results
54+ gitleaks dir . \
55+ --no-banner \
56+ --redact=100 \
57+ --report-format json \
58+ --report-path secret-scan-results/gitleaks-tree-findings.json \
59+ --exit-code 1
60+
61+ - name : Scan git history
62+ shell : bash
63+ run : |
64+ set -euo pipefail
65+ mkdir -p secret-scan-results
66+ gitleaks git . \
67+ --log-opts="--all --full-history -m" \
68+ --no-banner \
69+ --redact=100 \
70+ --report-format json \
71+ --report-path secret-scan-results/gitleaks-history-findings.json \
72+ --exit-code 1
73+
74+ - name : Upload redacted scan report
75+ if : failure()
76+ uses : actions/upload-artifact@v4
77+ with :
78+ name : gitleaks-redacted-findings
79+ path : secret-scan-results/*.json
80+ if-no-files-found : ignore
You can’t perform that action at this time.
0 commit comments