mirror of
https://github.com/actions/runner-images.git
synced 2026-01-09 03:57:44 +08:00
* [ubuntu, windows] cast "run_id" to 32 bit unsigned to match BuildId
restriction
./images.CI/linux-and-win/create-release.ps1 `
-BuildId 5621210575 `
-Organization *** `
-DefinitionId *** `
-Project *** `
-ImageName ubuntu2204 `
-AccessToken ***
shell: /usr/bin/pwsh -command ". '{0}'"
env:
CHECKOUT_TYPE: pull_request
TemplatePath: /home/vsts/Agents/image-generation/_work/runner-images/runner-images/images/linux/ubuntu2204.pkr.hcl
TemplateDirectoryPath: /home/vsts/Agents/image-generation/_work/runner-images/runner-images/images/linux
ImageType: ubuntu2204
create-release.ps1: /home/vsts/Agents/image-generation/_work/_temp/ee00e9c3-e508-4c8d-b369-ffe3e2afcbc9.ps1:3
Line |
3 | -BuildId 5621210575 `
| ~~~~~~~~~~
| Cannot process argument transformation on parameter 'BuildId'. Cannot
| convert value "5621210575" to type "System.UInt32". Error: "Value was
| either too large or too small for a UInt32."
* cast another occurence to UInt32 MaxValue
134 lines
5.1 KiB
YAML
134 lines
5.1 KiB
YAML
name: MMS image generation
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
image_name:
|
|
type: string
|
|
description: An OS image to build
|
|
required: true
|
|
image_readme_name:
|
|
type: string
|
|
description: README file path
|
|
required: true
|
|
custom_repo:
|
|
type: string
|
|
description: Custom repo to checkout
|
|
required: false
|
|
custom_repo_commit_hash:
|
|
type: string
|
|
description: Custom repo commit hash
|
|
required: false
|
|
defaults:
|
|
run:
|
|
shell: pwsh
|
|
|
|
jobs:
|
|
build:
|
|
#
|
|
# "azure-builds" is dedicated runner not available in forks.
|
|
# to reduce undesired run attempts in forks, stick jobs to "actions" organization only
|
|
#
|
|
runs-on: azure-builds
|
|
if: ${{ github.repository_owner == 'actions' }}
|
|
timeout-minutes: 1200
|
|
steps:
|
|
- name: Determine checkout type
|
|
run: |
|
|
if ("${{ inputs.custom_repo }}" -and "${{ inputs.custom_repo_commit_hash }}") {
|
|
$checkoutType = "custom_repo"
|
|
} elseif (("${{ github.event_name }}" -eq "pull_request_target") -and ("${{ github.event.action }}" -eq "labeled" )) {
|
|
$checkoutType = "pull_request"
|
|
} else {
|
|
$checkoutType = "main"
|
|
}
|
|
"CHECKOUT_TYPE=$checkoutType" | Out-File -Append $env:GITHUB_ENV
|
|
|
|
- name: Checkout repository
|
|
if: ${{ env.CHECKOUT_TYPE == 'main' }}
|
|
uses: actions/checkout@v3
|
|
with:
|
|
repository: actions/runner-images
|
|
|
|
- name: Checkout PR
|
|
if: ${{ env.CHECKOUT_TYPE == 'pull_request' }}
|
|
uses: actions/checkout@v3
|
|
with:
|
|
ref: ${{ github.event.pull_request.head.sha }}
|
|
|
|
- name: Checkout custom repository
|
|
if: ${{ env.CHECKOUT_TYPE == 'custom_repo' }}
|
|
uses: actions/checkout@v3
|
|
with:
|
|
repository: '${{ inputs.custom_repo }}'
|
|
ref: '${{ inputs.custom_repo_commit_hash }}'
|
|
|
|
- name: Set image variables
|
|
run: |
|
|
$ImageType = "${{ inputs.image_name }}"
|
|
|
|
if ($ImageType.StartsWith("ubuntu")) { $TemplateDirectoryName = "linux" } else { $TemplateDirectoryName = "win" }
|
|
|
|
$TemplateDirectoryPath = Join-Path "images" $TemplateDirectoryName | Resolve-Path
|
|
$TemplatePath = Join-Path $TemplateDirectoryPath "$ImageType.pkr.hcl"
|
|
|
|
if ( -not (Test-Path $TemplatePath) ) {
|
|
$TemplatePath = Join-Path $TemplateDirectoryPath "$ImageType.json"
|
|
}
|
|
|
|
"TemplatePath=$TemplatePath" | Out-File -Append -FilePath $env:GITHUB_ENV
|
|
"TemplateDirectoryPath=$TemplateDirectoryPath" | Out-File -Append -FilePath $env:GITHUB_ENV
|
|
"ImageType=$ImageType" | Out-File -Append -FilePath $env:GITHUB_ENV
|
|
|
|
- name: Build image
|
|
run: |
|
|
./images.CI/linux-and-win/build-image.ps1 `
|
|
-TemplatePath ${{ env.TemplatePath }} `
|
|
-ClientId ${{ secrets.CLIENT_ID }} `
|
|
-ClientSecret ${{ secrets.CLIENT_SECRET }} `
|
|
-Location ${{ secrets.AZURE_LOCATION }} `
|
|
-ResourcesNamePrefix ${{ github.run_id }} % [System.UInt32]::MaxValue `
|
|
-ResourceGroup ${{ secrets.AZURE_RESOURCE_GROUP }} `
|
|
-StorageAccount ${{ secrets.AZURE_STORAGE_ACCOUNT }} `
|
|
-SubscriptionId ${{ secrets.AZURE_SUBSCRIPTION }} `
|
|
-TenantId ${{ secrets.AZURE_TENANT }} `
|
|
-VirtualNetworkName ${{ secrets.BUILD_AGENT_VNET_NAME }} `
|
|
-VirtualNetworkSubnet ${{ secrets.BUILD_AGENT_SUBNET_NAME }} `
|
|
-VirtualNetworkRG ${{ secrets.BUILD_AGENT_VNET_RESOURCE_GROUP }} `
|
|
env:
|
|
PACKER_LOG: 1
|
|
PACKER_LOG_PATH: ${{ runner.temp }}/packer-log.txt
|
|
RUN_VALIDATION_FLAG: true
|
|
|
|
- name: Output Readme file content
|
|
run: |
|
|
Get-Content -Path (Join-Path "$env:TemplateDirectoryPath" "${{ inputs.image_readme_name }}")
|
|
|
|
- name: Print provisioners duration
|
|
run: |
|
|
./images.CI/measure-provisioners-duration.ps1 `
|
|
-PackerLogPath "${{ runner.temp }}/packer-log.txt" `
|
|
-PrefixToPathTrim ${{ env.TemplateDirectoryPath }} `
|
|
-PrintTopNLongest 25
|
|
|
|
- name: Create release for VM deployment
|
|
run: |
|
|
./images.CI/linux-and-win/create-release.ps1 `
|
|
-BuildId ${{ github.run_id }} % [System.UInt32]::MaxValue `
|
|
-Organization ${{ secrets.RELEASE_TARGET_ORGANIZATION }} `
|
|
-DefinitionId ${{ secrets.RELEASE_TARGET_DEFINITION_ID }} `
|
|
-Project ${{ secrets.RELEASE_TARGET_PROJECT }} `
|
|
-ImageName ${{ env.ImageType }} `
|
|
-AccessToken ${{ secrets.RELEASE_TARGET_TOKEN }}
|
|
|
|
- name: Clean up resources
|
|
if: ${{ always() }}
|
|
run: |
|
|
./images.CI/linux-and-win/cleanup.ps1 `
|
|
-ResourcesNamePrefix ${{ github.run_number }} `
|
|
-Image ${{ env.ImageType }} `
|
|
-StorageAccount ${{ secrets.AZURE_STORAGE_ACCOUNT }} `
|
|
-SubscriptionId ${{ secrets.AZURE_SUBSCRIPTION }} `
|
|
-ClientId ${{ secrets.CLIENT_ID }} `
|
|
-ClientSecret ${{ secrets.CLIENT_SECRET }} `
|
|
-TenantId ${{ secrets.AZURE_TENANT }}
|