Skip to content

Commit 1da1032

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

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

Diff for: action.yml

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

0 commit comments

Comments
 (0)