mirror of
https://github.com/actions/runner-images.git
synced 2025-12-14 22:05:17 +00:00
Add cleanup logic for the packer os disk (#3140)
This commit is contained in:
@@ -92,8 +92,9 @@ jobs:
|
||||
targetType: filePath
|
||||
filePath: ./images.CI/linux-and-win/cleanup.ps1
|
||||
arguments: -ResourcesNamePrefix $(Build.BuildId) `
|
||||
-Image ${{ parameters.image_type }} `
|
||||
-StorageAccount $(AZURE_STORAGE_ACCOUNT) `
|
||||
-SubscriptionId $(AZURE_SUBSCRIPTION) `
|
||||
-ClientId $(CLIENT_ID) `
|
||||
-ClientSecret $(CLIENT_SECRET) `
|
||||
-Image ${{ parameters.image_type }} `
|
||||
-SubscriptionId $(AZURE_SUBSCRIPTION) `
|
||||
-TenantId $(AZURE_TENANT)
|
||||
|
||||
@@ -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