mirror of
https://github.com/actions/runner-images.git
synced 2026-01-04 09:13:33 +08:00
Fix macOS CI - clean images updates (#9032)
This commit is contained in:
@@ -266,36 +266,13 @@ function Install-SoftwareUpdate {
|
||||
[array] $listOfUpdates,
|
||||
[string] $Password
|
||||
)
|
||||
# If an update is happening on macOS 12 or 13 we will use the prepared list of updates, otherwise, we will install all updates.
|
||||
$command = "sw_vers"
|
||||
$guestMacosVersion = Invoke-SSHPassCommand -HostName $HostName -Command $command
|
||||
if ($guestMacosVersion[1] -match "12") {
|
||||
foreach ($update in $listOfUpdates) {
|
||||
# Filtering updates that contain "Ventura" word
|
||||
if ($update -notmatch "Ventura") {
|
||||
$command = "sudo /usr/sbin/softwareupdate --restart --verbose --install '$($update.trim())'"
|
||||
Invoke-SSHPassCommand -HostName $HostName -Command $command
|
||||
}
|
||||
}
|
||||
} elseif ($guestMacosVersion[1] -match "13") {
|
||||
$osArch = $(arch)
|
||||
if ($osArch -eq "arm64") {
|
||||
Invoke-SoftwareUpdateArm64 -HostName $HostName -Password $Password -ListOfUpdates $listOfUpdates
|
||||
} else {
|
||||
foreach ($update in $listOfUpdates) {
|
||||
# Filtering updates that contain "Sonoma" word
|
||||
if ($update -notmatch "Sonoma") {
|
||||
$command = "sudo /usr/sbin/softwareupdate --restart --verbose --install '$($update.trim())'"
|
||||
Invoke-SSHPassCommand -HostName $HostName -Command $command
|
||||
}
|
||||
}
|
||||
}
|
||||
# If an update is happening on macOS arm64 we will use the additional tool to install updates.
|
||||
$osArch = $(arch)
|
||||
if ($osArch -eq "arm64") {
|
||||
Invoke-SoftwareUpdateArm64 -HostName $HostName -Password $Password -ListOfUpdates $listOfUpdates
|
||||
} else {
|
||||
$osArch = $(arch)
|
||||
if ($osArch -eq "arm64") {
|
||||
Invoke-SoftwareUpdateArm64 -HostName $HostName -Password $Password -ListOfUpdates $listOfUpdates
|
||||
} else {
|
||||
$command = "sudo /usr/sbin/softwareupdate --all --install --restart --verbose"
|
||||
foreach ($update in $listOfUpdates) {
|
||||
$command = "sudo /usr/sbin/softwareupdate --restart --verbose --install '$($update.trim())'"
|
||||
Invoke-SSHPassCommand -HostName $HostName -Command $command
|
||||
}
|
||||
}
|
||||
@@ -348,14 +325,17 @@ function Invoke-WithRetry {
|
||||
[int] $RetryCount = 20,
|
||||
[int] $Seconds = 60
|
||||
)
|
||||
|
||||
while ($RetryCount -gt 0) {
|
||||
if ($Command) {
|
||||
$result = & $Command
|
||||
}
|
||||
try {
|
||||
if ($Command) {
|
||||
$result = & $Command
|
||||
}
|
||||
|
||||
if (& $BreakCondition) {
|
||||
return $result
|
||||
if (& $BreakCondition) {
|
||||
return $result
|
||||
}
|
||||
} catch {
|
||||
Write-Host "`t [!] Error during command execution: $_"
|
||||
}
|
||||
|
||||
$RetryCount--
|
||||
|
||||
Reference in New Issue
Block a user