mirror of
https://github.com/actions/runner-images.git
synced 2025-12-18 15:57:17 +00:00
The error happens because we try to stop the Explorer process which may not running, so let's check first if the process is running.
63 lines
2.5 KiB
PowerShell
63 lines
2.5 KiB
PowerShell
param(
|
|
[String] [Parameter (Mandatory=$true)] $Image,
|
|
[String] [Parameter (Mandatory=$true)] $ClientId,
|
|
[String] [Parameter (Mandatory=$true)] $ClientSecret,
|
|
[String] [Parameter (Mandatory=$true)] $GitHubFeedToken,
|
|
[String] [Parameter (Mandatory=$true)] $ResourcesNamePrefix,
|
|
[String] [Parameter (Mandatory=$true)] $Location,
|
|
[String] [Parameter (Mandatory=$true)] $ResourceGroup,
|
|
[String] [Parameter (Mandatory=$true)] $StorageAccount,
|
|
[String] [Parameter (Mandatory=$true)] $SubscriptionId,
|
|
[String] [Parameter (Mandatory=$true)] $TenantId,
|
|
[String] [Parameter (Mandatory=$true)] $VirtualNetworkName,
|
|
[String] [Parameter (Mandatory=$true)] $VirtualNetworkRG,
|
|
[String] [Parameter (Mandatory=$true)] $VirtualNetworkSubnet
|
|
)
|
|
|
|
$TemplatePath = (Get-ChildItem -Path "images" -Include "$Image.json" -Recurse -Depth 2).FullName
|
|
if (-not $TemplatePath)
|
|
{
|
|
Write-Error "'-Image' parameter is not valid. You have to specify correct image type."
|
|
exit 1
|
|
}
|
|
|
|
$TempResourceGroupName = "${ResourcesNamePrefix}_${Image}"
|
|
$InstallPassword = [System.GUID]::NewGuid().ToString().ToUpper()
|
|
|
|
packer validate -syntax-only $TemplatePath
|
|
|
|
$SensitiveData = @(
|
|
'OSType',
|
|
'StorageAccountLocation',
|
|
'OSDiskUri',
|
|
'OSDiskUriReadOnlySas',
|
|
'TemplateUri',
|
|
'TemplateUriReadOnlySas',
|
|
': ->'
|
|
)
|
|
|
|
Write-Host "Show Packer Version"
|
|
packer --version
|
|
|
|
Write-Host "Build $Image VM"
|
|
packer build -var "capture_name_prefix=$ResourcesNamePrefix" `
|
|
-var "client_id=$ClientId" `
|
|
-var "client_secret=$ClientSecret" `
|
|
-var "install_password=$InstallPassword" `
|
|
-var "github_feed_token=$GitHubFeedToken" `
|
|
-var "location=$Location" `
|
|
-var "resource_group=$ResourceGroup" `
|
|
-var "storage_account=$StorageAccount" `
|
|
-var "subscription_id=$SubscriptionId" `
|
|
-var "temp_resource_group_name=$TempResourceGroupName" `
|
|
-var "tenant_id=$TenantId" `
|
|
-var "virtual_network_name=$VirtualNetworkName" `
|
|
-var "virtual_network_resource_group_name=$VirtualNetworkRG" `
|
|
-var "virtual_network_subnet_name=$VirtualNetworkSubnet" `
|
|
$TemplatePath `
|
|
| Where-Object {
|
|
#Filter sensitive data from Packer logs
|
|
$currentString = $_
|
|
$sensitiveString = $SensitiveData | Where-Object { $currentString -match $_ }
|
|
$sensitiveString -eq $null
|
|
} |