Skip to content

Commit b15ead9

Browse files
🩹 [Patch]: Enhance module installation with retry logic in Action-Test workflow
1 parent a2c4cfb commit b15ead9

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

‎.github/workflows/Action-Test.yml‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,26 @@ jobs:
138138
uses: PSModule/Github-Script@v1
139139
with:
140140
Script: |
141-
Install-PSResource -Name Markdown -Repository PSGallery -TrustRepository
141+
'Markdown' | ForEach-Object {
142+
$name = $_
143+
Write-Output "Installing module: $name"
144+
$retryCount = 5
145+
$retryDelay = 10
146+
for ($i = 0; $i -lt $retryCount; $i++) {
147+
try {
148+
Install-PSResource -Name $name -WarningAction SilentlyContinue -TrustRepository -Repository PSGallery
149+
break
150+
} catch {
151+
Write-Warning "Installation of $name failed with error: $_"
152+
if ($i -eq $retryCount - 1) {
153+
throw
154+
}
155+
Write-Warning "Retrying in $retryDelay seconds..."
156+
Start-Sleep -Seconds $retryDelay
157+
}
158+
}
159+
Import-Module -Name $name
160+
}
142161
143162
# Build an array of objects for each job
144163
$ActionTestSrcSourceCodeExpectedOutcome = 'success'

0 commit comments

Comments
 (0)