Skip to content

Commit fcd435e

Browse files
Add n-2 truffle get when n-1 is unavailable (#191)
1 parent 2b199dd commit fcd435e

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

.github/workflows/secret-scan.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,21 @@ jobs:
2121
env:
2222
GH_TOKEN: ${{ github.token }}
2323
run: |
24-
LATEST_TAG_NAME=$(gh api repos/trufflesecurity/trufflehog/releases --jq '.[1].tag_name')
24+
RELEASES=$(gh api repos/trufflesecurity/trufflehog/releases --jq '.[1:3][].tag_name')
2525
26-
if [[ -z "$LATEST_TAG_NAME" || "$LATEST_TAG_NAME" == "null" ]]; then
27-
echo "::error::Failed to fetch TruffleHog release info"
26+
LATEST_TAG_NAME=""
27+
for tag in $RELEASES; do
28+
version="${tag#v}"
29+
url="https://github.com/trufflesecurity/trufflehog/releases/download/${tag}/trufflehog_${version}_linux_amd64.tar.gz"
30+
if curl --head --fail --silent --show-error --retry 2 --retry-delay 3 --retry-all-errors "$url" > /dev/null 2>&1; then
31+
LATEST_TAG_NAME="$tag"
32+
break
33+
fi
34+
echo "::warning::Release ${tag} assets unavailable, trying next"
35+
done
36+
37+
if [[ -z "$LATEST_TAG_NAME" ]]; then
38+
echo "::error::No usable TruffleHog release found"
2839
exit 1
2940
fi
3041

0 commit comments

Comments
 (0)