Skip to content

Commit 8639f70

Browse files
authored
Make gitleaks version detection more resilient (#19)
1 parent 2cf2fb7 commit 8639f70

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

action.yml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,26 @@ runs:
8181
platform=$(echo $arch | tr '[:upper:]' '[:lower:]' )
8282
platform="${platform//aarch64/arm64}"
8383
platform="${platform//x86_64/x64}"
84-
version_tag="$(curl --retry 5 -s https://api.github.com/repos/gitleaks/gitleaks/releases/latest | jq -r .name)"
84+
85+
max_attempts=5
86+
attempt=0
87+
while [[ $attempt -lt $max_attempts ]]; do
88+
version_tag="$(curl --retry 5 -s -f https://api.github.com/repos/gitleaks/gitleaks/releases/latest | jq -r .name)"
89+
version="${version_tag#v}"
90+
if [[ -n "$version" ]]; then
91+
break
92+
fi
93+
attempt=$((attempt + 1))
94+
echo "::warning::Attempt $attempt failed to fetch version, retrying in 60 seconds..." >&2
95+
sleep 60
96+
done
97+
98+
if [[ -z "$version" ]]; then
99+
echo "::error::Failed to fetch Gitleaks version after $max_attempts attempts." >&2
100+
exit 1
101+
fi
85102
echo "platform=$platform" >> $GITHUB_OUTPUT
86-
echo "version=${version_tag#v}" >> $GITHUB_OUTPUT
103+
echo "version=${version}" >> $GITHUB_OUTPUT
87104
88105
- name: Install gitleaks (macos)
89106
if: runner.os == 'macOS'

0 commit comments

Comments
 (0)