Skip to content

Commit 0e67f83

Browse files
authored
ci: PLT-770: update gitleks (#778)
1 parent 84d698a commit 0e67f83

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

.github/workflows/gitleaks.yml

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ on:
44
pull_request:
55

66
env:
7-
GIT_GITLEAKS_VERSION: 8.18.4
87
ACTIONS_STEP_DEBUG: '${{ secrets.ACTIONS_STEP_DEBUG }}'
98

109
jobs:
@@ -14,19 +13,32 @@ jobs:
1413
steps:
1514
- uses: hmarr/[email protected]
1615

17-
- name: Configure gitleaks binary cache
18-
id: cache
16+
- name: Install
17+
shell: bash
18+
run: |
19+
set -euo pipefail
20+
arch="$(uname)_$(uname -m)"
21+
platform=$(echo $arch | tr '[:upper:]' '[:lower:]' )
22+
echo "PLATFORM=$platform" >> $GITHUB_ENV
23+
echo "GITLEAKS_VERSION=$(curl -s https://api.github.com/repos/gitleaks/gitleaks/releases/latest | grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/')" >> $GITHUB_ENV
24+
25+
- name: Cache gitleaks archive
26+
id: cache_gitleaks
1927
uses: actions/cache@v4
2028
with:
2129
path: /usr/local/bin/gitleaks
22-
key: gitleaks-${{ env.GIT_GITLEAKS_VERSION }}
30+
key: gitleaks-${{ env.PLATFORM }}-${{ env.GITLEAKS_VERSION }}
2331

24-
- name: Install tools
25-
if: steps.cache.outputs.cache-hit != 'true'
32+
- name: Download and configure gitleaks
33+
shell: bash
2634
run: |
27-
wget -O - \
28-
"https://github.com/zricethezav/gitleaks/releases/download/v${{ env.GIT_GITLEAKS_VERSION }}/gitleaks_${{ env.GIT_GITLEAKS_VERSION }}_linux_x64.tar.gz" \
29-
| sudo tar xzf - -C /usr/local/bin
35+
set -euo pipefail
36+
if [[ "${{ steps.cache_gitleaks.outputs.cache-hit }}" != "true" ]]; then
37+
DOWNLOAD_URL="https://github.com/gitleaks/gitleaks/releases/download/v${{ env.GITLEAKS_VERSION }}/gitleaks_${{ env.GITLEAKS_VERSION }}_linux_x64.tar.gz"
38+
echo "Download Gitleaks ${{ env.GITLEAKS_VERSION }} for ${{ env.PLATFORM }} from ${DOWNLOAD_URL}"
39+
curl -fsSL "$DOWNLOAD_URL" | tar xzf - -C /usr/local/bin
40+
fi
41+
chmod +x /usr/local/bin/gitleaks
3042
3143
- name: Checkout
3244
uses: actions/checkout@v4

0 commit comments

Comments
 (0)