mirror of
https://github.com/actions/runner-images.git
synced 2025-12-12 12:06:59 +00:00
Update GenerateResourcesAndImage.ps1
This commit is contained in:
@@ -16,27 +16,42 @@ Function Get-PackerTemplatePath {
|
|||||||
[ImageType] $ImageType
|
[ImageType] $ImageType
|
||||||
)
|
)
|
||||||
|
|
||||||
$relativePath = "N/A"
|
|
||||||
|
|
||||||
switch ($ImageType) {
|
switch ($ImageType) {
|
||||||
([ImageType]::Windows2016) {
|
([ImageType]::Windows2016) {
|
||||||
$relativePath = "\images\win\windows2016.json"
|
$relativeTemplatePath = Join-Path "win" "windows2016.json"
|
||||||
}
|
}
|
||||||
([ImageType]::Windows2019) {
|
([ImageType]::Windows2019) {
|
||||||
$relativePath = "\images\win\windows2019.json"
|
$relativeTemplatePath = Join-Path "win" "windows2019.json"
|
||||||
}
|
}
|
||||||
([ImageType]::Ubuntu1604) {
|
([ImageType]::Ubuntu1604) {
|
||||||
$relativePath = "\images\linux\ubuntu1604.json"
|
$relativeTemplatePath = Join-Path "linux" "ubuntu1604.json"
|
||||||
}
|
}
|
||||||
([ImageType]::Ubuntu1804) {
|
([ImageType]::Ubuntu1804) {
|
||||||
$relativePath = "\images\linux\ubuntu1804.json"
|
$relativeTemplatePath = Join-Path "linux" "ubuntu1804.json"
|
||||||
}
|
}
|
||||||
([ImageType]::Ubuntu2004) {
|
([ImageType]::Ubuntu2004) {
|
||||||
$relativePath = "\images\linux\ubuntu2004.json"
|
$relativeTemplatePath = Join-Path "linux" "ubuntu2004.json"
|
||||||
}
|
}
|
||||||
|
default { throw "Unknown type of image" }
|
||||||
}
|
}
|
||||||
|
|
||||||
return $RepositoryRoot + $relativePath;
|
$imageTemplatePath = [IO.Path]::Combine($RepositoryRoot, "images", $relativeTemplatePath)
|
||||||
|
|
||||||
|
if (-not (Test-Path $imageTemplatePath)) {
|
||||||
|
throw "Template for image '$ImageType' doesn't exist on path '$imageTemplatePath'"
|
||||||
|
}
|
||||||
|
|
||||||
|
return $imageTemplatePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
Function Get-LatestCommit {
|
||||||
|
[CmdletBinding()]
|
||||||
|
param()
|
||||||
|
|
||||||
|
process {
|
||||||
|
Write-Host "Latest commit:"
|
||||||
|
git --no-pager log --pretty=format:"Date: %cd; Commit: %H - %s; Author: %an <%ae>" -1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Function Get-LatestCommit {
|
Function Get-LatestCommit {
|
||||||
@@ -87,12 +102,12 @@ Function GenerateResourcesAndImage {
|
|||||||
[Parameter(Mandatory = $True)]
|
[Parameter(Mandatory = $True)]
|
||||||
[string] $ResourceGroupName,
|
[string] $ResourceGroupName,
|
||||||
[Parameter(Mandatory = $True)]
|
[Parameter(Mandatory = $True)]
|
||||||
[string] $ImageGenerationRepositoryRoot,
|
|
||||||
[Parameter(Mandatory = $True)]
|
|
||||||
[ImageType] $ImageType,
|
[ImageType] $ImageType,
|
||||||
[Parameter(Mandatory = $True)]
|
[Parameter(Mandatory = $True)]
|
||||||
[string] $AzureLocation,
|
[string] $AzureLocation,
|
||||||
[Parameter(Mandatory = $False)]
|
[Parameter(Mandatory = $False)]
|
||||||
|
[string] $ImageGenerationRepositoryRoot = $pwd,
|
||||||
|
[Parameter(Mandatory = $False)]
|
||||||
[int] $SecondsToWaitForServicePrincipalSetup = 30,
|
[int] $SecondsToWaitForServicePrincipalSetup = 30,
|
||||||
[Parameter(Mandatory = $False)]
|
[Parameter(Mandatory = $False)]
|
||||||
[string] $GithubFeedToken,
|
[string] $GithubFeedToken,
|
||||||
@@ -184,7 +199,12 @@ Function GenerateResourcesAndImage {
|
|||||||
|
|
||||||
Get-LatestCommit -ErrorAction SilentlyContinue
|
Get-LatestCommit -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
packer.exe build -on-error=ask `
|
$packerBinary = Get-Command "packer"
|
||||||
|
if (-not ($packerBinary)) {
|
||||||
|
throw "'packer' binary is not found on PATH"
|
||||||
|
}
|
||||||
|
|
||||||
|
& $packerBinary build -on-error=ask `
|
||||||
-var "client_id=$($spClientId)" `
|
-var "client_id=$($spClientId)" `
|
||||||
-var "client_secret=$($ServicePrincipalClientSecret)" `
|
-var "client_secret=$($ServicePrincipalClientSecret)" `
|
||||||
-var "subscription_id=$($SubscriptionId)" `
|
-var "subscription_id=$($SubscriptionId)" `
|
||||||
|
|||||||
Reference in New Issue
Block a user