mirror of
https://github.com/actions/runner-images-sangeeth.git
synced 2025-12-20 06:29:50 +00:00
Merge pull request #1 from akv-platform/v-mazhuk/image-generation-azdo
Configure image CI pipelines
This commit is contained in:
39
images.CI/azure-pipelines/image-generation.yml
Normal file
39
images.CI/azure-pipelines/image-generation.yml
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
jobs:
|
||||||
|
- job:
|
||||||
|
pool: ci-agent-pool
|
||||||
|
timeoutInMinutes: 600
|
||||||
|
variables:
|
||||||
|
- group: Image Generation Variables
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- task: PowerShell@2
|
||||||
|
displayName: 'Build VM'
|
||||||
|
inputs:
|
||||||
|
targetType: filePath
|
||||||
|
filePath: ./images.CI/build-image.ps1
|
||||||
|
arguments: -ResourcesNamePrefix $(Build.BuildNumber) `
|
||||||
|
-ClientId $(CLIENT_ID) `
|
||||||
|
-ClientSecret $(CLIENT_SECRET) `
|
||||||
|
-Image ${{ parameters.image_type }} `
|
||||||
|
-ResourceGroup $(AZURE_RESOURCE_GROUP) `
|
||||||
|
-StorageAccount $(AZURE_STORAGE_ACCOUNT) `
|
||||||
|
-SubscriptionId $(AZURE_SUBSCRIPTION) `
|
||||||
|
-TenantId $(AZURE_TENANT) `
|
||||||
|
-Location $(AZURE_LOCATION) `
|
||||||
|
-VirtualNetworkName $(BUILD_AGENT_VNET_NAME) `
|
||||||
|
-VirtualNetworkRG $(BUILD_AGENT_VNET_RESOURCE_GROUP) `
|
||||||
|
-VirtualNetworkSubnet $(BUILD_AGENT_SUBNET_NAME) `
|
||||||
|
-GitHubFeedToken $(GITHUB_TOKEN)
|
||||||
|
|
||||||
|
- task: PowerShell@2
|
||||||
|
displayName: 'Clean up resources'
|
||||||
|
condition: always()
|
||||||
|
inputs:
|
||||||
|
targetType: filePath
|
||||||
|
filePath: ./images.CI/cleanup.ps1
|
||||||
|
arguments: -ResourcesNamePrefix $(Build.BuildNumber) `
|
||||||
|
-ClientId $(CLIENT_ID) `
|
||||||
|
-ClientSecret $(CLIENT_SECRET) `
|
||||||
|
-Image ${{ parameters.image_type }} `
|
||||||
|
-SubscriptionId $(AZURE_SUBSCRIPTION) `
|
||||||
|
-TenantId $(AZURE_TENANT)
|
||||||
19
images.CI/azure-pipelines/ubuntu1604.yml
Normal file
19
images.CI/azure-pipelines/ubuntu1604.yml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
# schedules:
|
||||||
|
# - cron: "0 0 * * *"
|
||||||
|
# displayName: Daily
|
||||||
|
# branches:
|
||||||
|
# include:
|
||||||
|
# - master
|
||||||
|
# always: true
|
||||||
|
|
||||||
|
trigger: none
|
||||||
|
pr:
|
||||||
|
autoCancel: true
|
||||||
|
branches:
|
||||||
|
include:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
- template: image-generation.yml
|
||||||
|
parameters:
|
||||||
|
image_type: ubuntu1604
|
||||||
19
images.CI/azure-pipelines/ubuntu1804.yml
Normal file
19
images.CI/azure-pipelines/ubuntu1804.yml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
# schedules:
|
||||||
|
# - cron: "0 0 * * *"
|
||||||
|
# displayName: Daily
|
||||||
|
# branches:
|
||||||
|
# include:
|
||||||
|
# - master
|
||||||
|
# always: true
|
||||||
|
|
||||||
|
trigger: none
|
||||||
|
pr:
|
||||||
|
autoCancel: true
|
||||||
|
branches:
|
||||||
|
include:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
- template: image-generation.yml
|
||||||
|
parameters:
|
||||||
|
image_type: ubuntu1804
|
||||||
19
images.CI/azure-pipelines/windows2016.yml
Normal file
19
images.CI/azure-pipelines/windows2016.yml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
# schedules:
|
||||||
|
# - cron: "0 0 * * *"
|
||||||
|
# displayName: Daily
|
||||||
|
# branches:
|
||||||
|
# include:
|
||||||
|
# - master
|
||||||
|
# always: true
|
||||||
|
|
||||||
|
trigger: none
|
||||||
|
pr:
|
||||||
|
autoCancel: true
|
||||||
|
branches:
|
||||||
|
include:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
- template: image-generation.yml
|
||||||
|
parameters:
|
||||||
|
image_type: Windows2016-Azure
|
||||||
19
images.CI/azure-pipelines/windows2019.yml
Normal file
19
images.CI/azure-pipelines/windows2019.yml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
# schedules:
|
||||||
|
# - cron: "0 0 * * *"
|
||||||
|
# displayName: Daily
|
||||||
|
# branches:
|
||||||
|
# include:
|
||||||
|
# - master
|
||||||
|
# always: true
|
||||||
|
|
||||||
|
trigger: none
|
||||||
|
pr:
|
||||||
|
autoCancel: true
|
||||||
|
branches:
|
||||||
|
include:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
- template: image-generation.yml
|
||||||
|
parameters:
|
||||||
|
image_type: Windows2019-Azure
|
||||||
44
images.CI/build-image.ps1
Normal file
44
images.CI/build-image.ps1
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
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
|
||||||
|
|
||||||
|
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
|
||||||
21
images.CI/cleanup.ps1
Normal file
21
images.CI/cleanup.ps1
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
param(
|
||||||
|
[String] [Parameter (Mandatory=$true)] $Image,
|
||||||
|
[String] [Parameter (Mandatory=$true)] $ResourcesNamePrefix,
|
||||||
|
[String] [Parameter (Mandatory=$true)] $ClientId,
|
||||||
|
[String] [Parameter (Mandatory=$true)] $ClientSecret,
|
||||||
|
[String] [Parameter (Mandatory=$true)] $SubscriptionId,
|
||||||
|
[String] [Parameter (Mandatory=$true)] $TenantId
|
||||||
|
)
|
||||||
|
|
||||||
|
az login --service-principal --username $ClientId --password $ClientSecret --tenant $TenantId | Out-Null
|
||||||
|
|
||||||
|
$TempResourceGroupName = "${ResourcesNamePrefix}_${Image}"
|
||||||
|
|
||||||
|
$groupExist = az group exists --name $TempResourceGroupName --subscription $SubscriptionId | Out-Null
|
||||||
|
if ($groupExist -eq "true") {
|
||||||
|
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
|
||||||
|
} else {
|
||||||
|
Write-Host "No temporary groups found"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user