Skip to content

Commit 82a91d5

Browse files
committed
Add a retry mechanism for fetching setup executable
1 parent 19c4d14 commit 82a91d5

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

Diff for: action.yml

+22-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,28 @@ runs:
6767
6868
$setupExe = "$vol\setup.exe"
6969
$setupFileName = "setup-$platform.exe"
70-
Invoke-WebRequest "https://cygwin.com/$setupFileName" -OutFile $setupExe
70+
71+
$maxRetries = 5
72+
$retryCount = 0
73+
$success = $false
74+
$delay = 2
75+
76+
while (-not $success -and $retryCount -lt $maxRetries) {
77+
try {
78+
Invoke-WebRequest -Uri "https://cygwin.com/$setupFileName" -OutFile $setupExe
79+
$success = $true
80+
} catch {
81+
Write-Output "Attempt $($retryCount + 1) failed. Retrying..."
82+
Start-Sleep -Seconds $delay
83+
$retryCount++
84+
$delay += $delay
85+
}
86+
}
87+
88+
if (-not $success) {
89+
throw "Failed to download $setupFileName after $maxRetries attempts."
90+
}
91+
7192
if ((Get-Item -LiteralPath $setupExe).Length -eq 0) {
7293
throw "The downloaded setup has a zero length!"
7394
}

0 commit comments

Comments
 (0)