Files
runner-images/images/win/scripts/Installers/Update-ImageData.ps1
Maxim Lobanov 2e8f85a83b [Windows][Improvement] Split and simplify "InitializeVM.ps1" script (#3806)
* improve InitializeVM script

* Update windows2019.json

* remove configs

* resolve comments

* resolve comments; fix order

* fix templates
2021-07-29 10:46:27 +03:00

43 lines
1.4 KiB
PowerShell

$os = Get-CimInstance -ClassName Win32_OperatingSystem
$caption = $os.Caption
$osName = $caption.Substring(0, $caption.LastIndexOf(" "))
$osEdition = $caption.Substring($caption.LastIndexOf(" ")+1)
$osVersion = $os.Version
$imageVersion = $env:IMAGE_VERSION
$imageDataFile = $env:IMAGEDATA_FILE
$githubUrl="https://github.com/actions/virtual-environments/blob"
if ($caption -match "2019")
{
$imageLabel = "windows-2019"
$softwareUrl = "${githubUrl}/win19/${imageVersion}/images/win/Windows2019-Readme.md"
$releaseUrl="https://github.com/actions/virtual-environments/releases/tag/win19%2F${imageVersion}"
}
if ($caption -match "2016")
{
$imageLabel = "windows-2016"
$softwareUrl = "${githubUrl}/win16/${imageVersion}/images/win/Windows2016-Readme.md"
$releaseUrl="https://github.com/actions/virtual-environments/releases/tag/win16%2F${imageVersion}"
}
$json = @"
[
{
"group": "Operating System",
"detail": "${osName}\n${osVersion}\n${osEdition}"
},
{
"group": "Virtual Environment",
"detail": "Environment: ${imageLabel}\nVersion: ${imageVersion}\nIncluded Software: ${softwareUrl}\nImage Release: ${releaseUrl}"
}
]
"@
$json | Out-File -FilePath $imageDataFile
# Set static env vars
setx ImageVersion $env:IMAGE_VERSION /m
setx ImageOS $env:IMAGE_OS /m
setx AGENT_TOOLSDIRECTORY $env:AGENT_TOOLSDIRECTORY /m