mirror of
https://github.com/actions/runner-images-sangeeth.git
synced 2025-12-20 06:29:50 +00:00
Add cleanup logic for the packer os disk (#3140)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
param(
|
||||
[String] [Parameter (Mandatory=$true)] $Image,
|
||||
[String] [Parameter (Mandatory=$true)] $ResourcesNamePrefix,
|
||||
[String] [Parameter (Mandatory=$true)] $StorageAccount,
|
||||
[String] [Parameter (Mandatory=$true)] $ClientId,
|
||||
[String] [Parameter (Mandatory=$true)] $ClientSecret,
|
||||
[String] [Parameter (Mandatory=$true)] $SubscriptionId,
|
||||
@@ -13,9 +14,13 @@ $TempResourceGroupName = "${ResourcesNamePrefix}_${Image}"
|
||||
|
||||
$groupExist = az group exists --name $TempResourceGroupName --subscription $SubscriptionId
|
||||
if ($groupExist -eq "true") {
|
||||
$osDiskName = az group deployment list --resource-group $TempResourceGroupName --query "[].properties.parameters.osDiskName.value" -o tsv
|
||||
Write-Host "Found a match, deleting temporary files"
|
||||
az group delete --name $TempResourceGroupName --subscription $SubscriptionId --yes | Out-Null
|
||||
Write-Host "Temporary group was deleted succesfully" -ForegroundColor Green
|
||||
Write-Host "Temporary group was deleted succesfully"
|
||||
Write-Host "Deleting OS disk"
|
||||
az storage remove --account-name $StorageAccount -c "images" -n "$osDiskName.vhd" | Out-Null
|
||||
Write-Host "OS disk deleted"
|
||||
} else {
|
||||
Write-Host "No temporary groups found"
|
||||
}
|
||||
Reference in New Issue
Block a user