diff --git a/images/linux/scripts/installers/preimagedata.sh b/images/linux/scripts/installers/preimagedata.sh new file mode 100644 index 000000000..91b36a9cb --- /dev/null +++ b/images/linux/scripts/installers/preimagedata.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +imagedata_file=$IMAGEDATA_FILE +image_version=$IMAGE_VERSION +os_name=$(lsb_release -ds | sed "s/ /\\\n/g") +image_label="ubuntu-$(lsb_release -rs)" +github_url="https://github.com/actions/virtual-environments/blob" + +if [[ "$image_label" =~ "ubuntu-18" ]]; then + software_url="${github_url}/ubuntu18/${image_version}/images/linux/Ubuntu1804-README.md" +fi + +if [[ "$image_label" =~ "ubuntu-16" ]]; then + software_url="${github_url}/ubuntu16/${image_version}/images/linux/Ubuntu1604-README.md" +fi + +cat < $imagedata_file +[ + { + "group": "Operating System", + "detail": "${os_name}" + }, + { + "group": "Virtual Environment", + "detail": "Environment: ${image_label}\nVersion: ${image_version}\nIncluded Software: ${software_url}" + } +] +EOF \ No newline at end of file diff --git a/images/linux/ubuntu1604.json b/images/linux/ubuntu1604.json index 7cd93f76f..381c12245 100644 --- a/images/linux/ubuntu1604.json +++ b/images/linux/ubuntu1604.json @@ -15,6 +15,7 @@ "private_virtual_network_with_public_ip": "{{env `PRIVATE_VIRTUAL_NETWORK_WITH_PUBLIC_IP`}}", "image_folder": "/imagegeneration", "commit_file": "/imagegeneration/commit.txt", + "imagedata_file": "/imagegeneration/imagedata.json", "metadata_file": "/imagegeneration/metadatafile", "installer_script_folder": "/imagegeneration/installers", "helper_script_folder": "/imagegeneration/helpers", @@ -107,6 +108,17 @@ ], "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" }, + { + "type": "shell", + "scripts":[ + "{{template_dir}}/scripts/installers/preimagedata.sh" + ], + "environment_vars": [ + "IMAGE_VERSION={{user `image_version`}}", + "IMAGEDATA_FILE={{user `imagedata_file`}}" + ], + "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" + }, { "type": "shell", "inline": [ diff --git a/images/linux/ubuntu1804.json b/images/linux/ubuntu1804.json index 4153b200a..81c39eaeb 100644 --- a/images/linux/ubuntu1804.json +++ b/images/linux/ubuntu1804.json @@ -15,6 +15,7 @@ "private_virtual_network_with_public_ip": "{{env `PRIVATE_VIRTUAL_NETWORK_WITH_PUBLIC_IP`}}", "image_folder": "/imagegeneration", "commit_file": "/imagegeneration/commit.txt", + "imagedata_file": "/imagegeneration/imagedata.json", "metadata_file": "/imagegeneration/metadatafile", "installer_script_folder": "/imagegeneration/installers", "helper_script_folder": "/imagegeneration/helpers", @@ -110,6 +111,17 @@ ], "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" }, + { + "type": "shell", + "scripts":[ + "{{template_dir}}/scripts/installers/preimagedata.sh" + ], + "environment_vars": [ + "IMAGE_VERSION={{user `image_version`}}", + "IMAGEDATA_FILE={{user `imagedata_file`}}" + ], + "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" + }, { "type": "shell", "inline": [ diff --git a/images/win/Windows2016-Azure.json b/images/win/Windows2016-Azure.json index 944bed8c6..e24bd75e8 100644 --- a/images/win/Windows2016-Azure.json +++ b/images/win/Windows2016-Azure.json @@ -19,6 +19,7 @@ "root_folder": "C:", "image_folder": "C:\\image", "commit_file": "C:\\image\\commit.txt", + "imagedata_file": "C:\\imagedata.json", "metadata_file": "C:\\image\\metadata.txt", "helper_script_folder": "C:\\Program Files\\WindowsPowerShell\\Modules\\", "commit_url": "LATEST", @@ -120,6 +121,16 @@ "setx ImageOS {{user `image_os` }} /m" ] }, + { + "type": "powershell", + "environment_vars": [ + "IMAGE_VERSION={{user `image_version`}}", + "IMAGEDATA_FILE={{user `imagedata_file`}}" + ], + "scripts":[ + "{{ template_dir }}/scripts/Installers/Update-ImageData.ps1" + ] + }, { "type": "powershell", "scripts":[ diff --git a/images/win/Windows2019-Azure.json b/images/win/Windows2019-Azure.json index a8deb702d..668451eb5 100644 --- a/images/win/Windows2019-Azure.json +++ b/images/win/Windows2019-Azure.json @@ -19,6 +19,7 @@ "root_folder": "C:", "image_folder": "C:\\image", "commit_file": "C:\\image\\commit.txt", + "imagedata_file": "C:\\imagedata.json", "metadata_file": "C:\\image\\metadata.txt", "helper_script_folder": "C:\\Program Files\\WindowsPowerShell\\Modules\\", "commit_id": "LATEST", @@ -120,6 +121,16 @@ "setx ImageOS {{user `image_os` }} /m" ] }, + { + "type": "powershell", + "environment_vars": [ + "IMAGE_VERSION={{user `image_version`}}", + "IMAGEDATA_FILE={{user `imagedata_file`}}" + ], + "scripts":[ + "{{ template_dir }}/scripts/Installers/Update-ImageData.ps1" + ] + }, { "type": "powershell", "scripts":[ diff --git a/images/win/scripts/Installers/Update-ImageData.ps1 b/images/win/scripts/Installers/Update-ImageData.ps1 new file mode 100644 index 000000000..7cbffec0d --- /dev/null +++ b/images/win/scripts/Installers/Update-ImageData.ps1 @@ -0,0 +1,35 @@ +$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" +} + +if ($caption -match "2016") +{ + $imageLabel = "windows-2016" + $softwareUrl = "${githubUrl}/win16/${imageVersion}/images/win/Windows2016-Readme.md" +} + +$json = @" +[ + { + "group": "Operating System", + "detail": "${osName}\n${osVersion}\n${osEdition}" + }, + { + "group": "Virtual Environment", + "detail": "Environment: ${imageLabel}\nVersion: ${imageVersion}\nIncluded Software: ${softwareUrl}" + } +] +"@ + +$json | Out-File -FilePath $imageDataFile