Skip to content

Commit 8c13913

Browse files
🩹 [CI]: Improve GitHub module installation with retry logic in Build-Docs workflow
1 parent 604cd82 commit 8c13913

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

‎.github/workflows/Build-Docs.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,26 @@ jobs:
126126
- name: Reinstall GitHub module
127127
shell: pwsh
128128
run: |
129-
Install-PSResource -Name GitHub -TrustRepository -Reinstall
129+
'GitHub' | ForEach-Object {
130+
$name = $_
131+
Write-Output "Installing module: $name"
132+
$retryCount = 5
133+
$retryDelay = 10
134+
for ($i = 0; $i -lt $retryCount; $i++) {
135+
try {
136+
Install-PSResource -Name $name -WarningAction SilentlyContinue -TrustRepository -Repository PSGallery -Reinstall
137+
break
138+
} catch {
139+
Write-Warning "Installation of $name failed with error: $_"
140+
if ($i -eq $retryCount - 1) {
141+
throw
142+
}
143+
Write-Warning "Retrying in $retryDelay seconds..."
144+
Start-Sleep -Seconds $retryDelay
145+
}
146+
}
147+
Import-Module -Name $name
148+
}
130149
131150
- name: Structure site
132151
uses: PSModule/GitHub-Script@v1

0 commit comments

Comments
 (0)