mirror of
https://github.com/actions/runner-images.git
synced 2025-12-20 06:35:47 +00:00
[Windows] Reengineer the way of getting the installer for PostgreSQL (#7065)
This commit is contained in:
@@ -28,16 +28,22 @@ $TargetMinorVersions = ($MinorVersions | Sort-Object)[-1]
|
|||||||
$ErrorActionOldValue = $ErrorActionPreference
|
$ErrorActionOldValue = $ErrorActionPreference
|
||||||
$ErrorActionPreference = 'SilentlyContinue'
|
$ErrorActionPreference = 'SilentlyContinue'
|
||||||
# Starting from number 9 and going down, check if the installer is available. If yes, break the loop.
|
# Starting from number 9 and going down, check if the installer is available. If yes, break the loop.
|
||||||
foreach ($increment in 9..0) {
|
# If an installer with $TargetMinorVersions is not to be found, the $TargetMinorVersions will be decreased by 1
|
||||||
|
$increment = 9
|
||||||
|
do {
|
||||||
$url = "https://get.enterprisedb.com/postgresql/postgresql-$toolsetVersion.$TargetMinorVersions-$increment-windows-x64.exe"
|
$url = "https://get.enterprisedb.com/postgresql/postgresql-$toolsetVersion.$TargetMinorVersions-$increment-windows-x64.exe"
|
||||||
$checkaccess = [System.Net.WebRequest]::Create($url)
|
$checkaccess = [System.Net.WebRequest]::Create($url)
|
||||||
$response = $null
|
$response = $null
|
||||||
$response = $checkaccess.GetResponse()
|
$response = $checkaccess.GetResponse()
|
||||||
if ($response) {
|
if ($response) {
|
||||||
$InstallerUrl = $response.ResponseUri.OriginalString
|
$InstallerUrl = $response.ResponseUri.OriginalString
|
||||||
break
|
} elseif (!$response -and ($increment -eq 0)) {
|
||||||
}
|
$increment = 9
|
||||||
|
$TargetMinorVersions--
|
||||||
|
} else {
|
||||||
|
$increment--
|
||||||
}
|
}
|
||||||
|
} while (!$response)
|
||||||
# Return the previous value of ErrorAction and invoke Install-Binary function
|
# Return the previous value of ErrorAction and invoke Install-Binary function
|
||||||
$ErrorActionPreference = $ErrorActionOldValue
|
$ErrorActionPreference = $ErrorActionOldValue
|
||||||
$InstallerName = $InstallerUrl.Split('/')[-1]
|
$InstallerName = $InstallerUrl.Split('/')[-1]
|
||||||
|
|||||||
Reference in New Issue
Block a user