File tree Expand file tree Collapse file tree 1 file changed +84
-0
lines changed
Expand file tree Collapse file tree 1 file changed +84
-0
lines changed Original file line number Diff line number Diff line change 1+ name : " Gitleaks"
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+ tags-ignore :
8+ - ' **'
9+ pull_request :
10+ types :
11+ - opened
12+ - synchronize
13+ - reopened
14+ - ready_for_review
15+ branches :
16+ - main
17+ - ' release/**'
18+
19+ env :
20+ ACTIONS_STEP_DEBUG : ' ${{ secrets.ACTIONS_STEP_DEBUG }}'
21+
22+ jobs :
23+ gitleaks :
24+ name : " Gitleaks"
25+ runs-on : ubuntu-latest
26+ steps :
27+ - uses : hmarr/debug-action@v3.0.0
28+
29+ - name : install
30+ shell : bash
31+ run : |
32+ set -euo pipefail
33+ arch="$(uname)_$(uname -m)"
34+ platform=$(echo $arch | tr '[:upper:]' '[:lower:]' )
35+ echo "PLATFORM=$platform" >> $GITHUB_ENV
36+ echo "GITLEAKS_VERSION=$(curl -s https://api.github.com/repos/gitleaks/gitleaks/releases/latest | grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/')" >> $GITHUB_ENV
37+
38+ - name : Cache gitleaks archive
39+ id : cache_gitleaks
40+ uses : actions/cache@v4
41+ with :
42+ path : /usr/local/bin/gitleaks
43+ key : gitleaks-${{ env.PLATFORM }}-${{ env.GITLEAKS_VERSION }}
44+
45+ - name : Download and configure gitleaks
46+ shell : bash
47+ run : |
48+ set -euo pipefail
49+ if [[ "${{ steps.cache_gitleaks.outputs.cache-hit }}" != "true" ]]; then
50+ DOWNLOAD_URL="https://github.com/gitleaks/gitleaks/releases/download/v${{ env.GITLEAKS_VERSION }}/gitleaks_${{ env.GITLEAKS_VERSION }}_linux_x64.tar.gz"
51+ echo "Download Gitleaks ${{ env.GITLEAKS_VERSION }} for ${{ env.PLATFORM }} from ${DOWNLOAD_URL}"
52+ curl -fsSL "$DOWNLOAD_URL" | tar xzf - -C /usr/local/bin
53+ fi
54+ chmod +x /usr/local/bin/gitleaks
55+
56+ - name : Checkout
57+ uses : actions/checkout@v4
58+ with :
59+ submodules : ' recursive'
60+ token : ${{ secrets.GIT_PAT }}
61+ fetch-depth : 0
62+
63+ - name : Run gitleaks
64+ run : |
65+ set -euo pipefail ${ACTIONS_STEP_DEBUG:+-x}
66+
67+ gitleaks \
68+ detect \
69+ --source="." \
70+ --redact \
71+ -v \
72+ --exit-code=2 \
73+ --report-format=sarif \
74+ --report-path=results.sarif \
75+ --log-level=debug \
76+ --log-opts='${{ github.event.pull_request.base.sha || github.event.before }}..${{ github.event.pull_request.head.sha || github.event.after }}'
77+
78+ - name : Upload test results
79+ if : failure()
80+ uses : actions/upload-artifact@v4
81+ with :
82+ name : GitLeaks results
83+ path : results.sarif
84+ retention-days : 14
You can’t perform that action at this time.
0 commit comments