Skip to content

Commit 10ad591

Browse files
authored
Merge pull request #77 from iMattPro/fix-windows
Fix IIS failures
2 parents 465e819 + e19c77b commit 10ad591

1 file changed

Lines changed: 27 additions & 3 deletions

File tree

‎.github/workflows/tests.yml‎

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -696,9 +696,33 @@ jobs:
696696
run: |
697697
Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebServerRole, IIS-WebServer, IIS-CommonHttpFeatures, IIS-ManagementConsole, IIS-HttpErrors, IIS-HttpRedirect, IIS-WindowsAuthentication, IIS-StaticContent, IIS-DefaultDocument, IIS-HttpCompressionStatic, IIS-DirectoryBrowsing, IIS-WebServerManagementTools, IIS-CGI -All
698698
Set-Service wuauserv -StartupType Manual
699-
(Get-Content ${env:GITHUB_WORKSPACE}\phpBB3\phpBB\web.config).replace("<configuration>", "<configuration>`n`t<system.web>`n`t`t<customErrors mode=`"Off`"/>`n`t</system.web>") | Set-Content ${env:GITHUB_WORKSPACE}\phpBB3\phpBB\web.config
700-
(Get-Content ${env:GITHUB_WORKSPACE}\phpBB3\phpBB\web.config).replace("`t</system.webServer>", "`t`t<httpErrors errorMode=`"Detailed`" />`n`t</system.webServer>") | Set-Content ${env:GITHUB_WORKSPACE}\phpBB3\phpBB\web.config
701-
choco install urlrewrite -y
699+
$webConfig = "${env:GITHUB_WORKSPACE}\phpBB3\phpBB\web.config"
700+
# Install URL Rewrite with retries because Chocolatey feed requests can timeout on GitHub runners.
701+
$installed = $false
702+
for ($i = 1; $i -le 3; $i++) {
703+
try {
704+
choco install urlrewrite -y --no-progress
705+
$installed = $true
706+
break
707+
} catch {
708+
Write-Warning "URL Rewrite install attempt $i failed: $($_.Exception.Message)"
709+
Start-Sleep -Seconds (10 * $i)
710+
}
711+
}
712+
if (-not $installed) {
713+
throw "Failed to install URL Rewrite after 3 attempts."
714+
}
715+
# Only patch web.config after rewrite is installed.
716+
$content = Get-Content $webConfig -Raw
717+
$content = $content.Replace(
718+
"<configuration>",
719+
"<configuration>`n`t<system.web>`n`t`t<customErrors mode=`"Off`"/>`n`t</system.web>"
720+
)
721+
$content = $content.Replace(
722+
"`t</system.webServer>",
723+
"`t`t<httpErrors errorMode=`"Detailed`" />`n`t</system.webServer>"
724+
)
725+
Set-Content $webConfig -Value $content -Encoding UTF8
702726
Import-Module WebAdministration
703727
New-WebSite -Name 'phpBBTest' -PhysicalPath "${env:GITHUB_WORKSPACE}\phpBB3\phpBB" -Force
704728
$session = Get-PSSession -Name WinPSCompatSession

0 commit comments

Comments
 (0)