Remove images GitHub Actions CI from repo (#8131)

This commit is contained in:
Mikhail Koliada
2023-08-22 10:35:20 +02:00
committed by GitHub
parent 6bf51e6351
commit 3f3600e029
9 changed files with 0 additions and 529 deletions

View File

@@ -1,55 +0,0 @@
run-name: Cleanup ${{ github.head_ref }}
on:
pull_request_target:
types: labeled
paths:
- 'images/**'
jobs:
clean_ci:
name: Clean CI runs
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: pwsh
run: |
$startDate = Get-Date -UFormat %s
$workflows = @("macos11", "macos12", "ubuntu2004", "ubuntu2204", "windows2019", "windows2022")
while ($true) {
$continue = $false
foreach ($wf in $workflows) {
$skippedCommand = "gh run list --workflow ${wf}.yml --branch ${{ github.event.pull_request.head.ref }} --repo ${{ github.repository }} --status skipped --json databaseId"
$skippedIds = Invoke-Expression -Command $skippedCommand | ConvertFrom-Json | ForEach-Object { $_.databaseId }
$skippedIds | ForEach-Object {
$deleteCommand = "gh run delete --repo ${{ github.repository }} $_"
Invoke-Expression -Command $deleteCommand
}
$pendingCommand = "gh run list --workflow ${wf}.yml --branch ${{ github.event.pull_request.head.ref }} --repo ${{ github.repository }} --status requested --json databaseId --template '{{ . | len }}'"
$pending = Invoke-Expression -Command $pendingCommand
if ($pending -gt 0) {
Write-Host "Pending for ${wf}.yml: $pending run(s)"
$continue = $true
}
}
if ($continue -eq $false) {
Write-Host "All done, exiting"
break
}
$curDate = Get-Date -UFormat %s
if (($curDate - $startDate) -gt 60) {
Write-Host "Reached timeout, exiting"
break
}
Write-Host "Waiting 5 seconds..."
Start-Sleep -Seconds 5
}

View File

@@ -1,207 +0,0 @@
name: macOS image generation
on:
workflow_call:
inputs:
image_label:
type: string
description: macOS codename
required: true
base_image_name:
type: string
description: Base clean image
required: true
template_path:
type: string
description: Packer template path
required: true
target_datastore:
type: string
description: Image datastore
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
env:
KEYVAULT: imagegeneration
ESXI_CLUSTER: mcv2-build-unstable
VCENTER_DATACENTER: imagegen
OUTPUT_FOLDER: mms-output
BUILD_DATASTORE: ds-image
defaults:
run:
shell: pwsh
jobs:
build:
#
# "macos-vmware" is dedicated runner not available in forks.
# to reduce undesired run attempts in forks, stick jobs to "actions" organization only
#
runs-on: macos-vmware
if: ${{ github.repository_owner == 'actions' }}
timeout-minutes: 1200
steps:
- name: Set image variables
run: |
$currentDate = Get-Date -Format "yyyyMMdd"
$templatePath = "${{ inputs.template_path }}"
$osName = $(($templatePath.Split("/")[-1]).Split(".")[0])
$virtualMachineName = "${osName}_${currentDate}_unstable.${{ github.run_id }}.${{ github.run_attempt }}"
"VM_NAME=$virtualMachineName" | Out-File -Append -FilePath $env:GITHUB_ENV
- 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: Validate contributor permissions
if: ${{ github.event_name == 'pull_request_target' }}
run: |
[string]$contributorAllowList = "${{ vars.CONTRIBUTOR_ALLOWLIST }}"
./images.CI/macos/validate-contributor.ps1 `
-RepositoryName ${{ github.repository }} `
-AccessToken ${{ secrets.GH_FEED }} `
-SourceBranch "refs/pull/${{ github.event.pull_request.number }}/merge" `
-ContributorAllowList $contributorAllowList
- name: Select datastore
run: |
./images.CI/macos/select-datastore.ps1 `
-VMName "${{ env.VM_NAME }}" `
-VIServer ${{ secrets.VISERVER_V2 }} `
-VIUserName ${{ secrets.VI_USER_NAME }} `
-VIPassword ${{ secrets.VI_PASSWORD }} `
-Cluster ${{ env.ESXI_CLUSTER }}
- name: Build VM
run: |
$SensitiveData = @(
'IP address:',
'Using ssh communicator to connect:'
)
packer build -on-error=abort `
-var="vcenter_server=${{ secrets.VISERVER_V2 }}" `
-var="vcenter_username=${{ secrets.VI_USER_NAME }}" `
-var="vcenter_password=${{ secrets.VI_PASSWORD }}" `
-var="vcenter_datacenter=${{ env.VCENTER_DATACENTER }}" `
-var="cluster_or_esxi_host=${{ env.ESXI_CLUSTER }}" `
-var="esxi_datastore=${{ env.BUILD_DATASTORE }}" `
-var="output_folder=${{ env.OUTPUT_FOLDER }}" `
-var="vm_username=${{ secrets.VM_USERNAME }}" `
-var="vm_password=${{ secrets.VM_PASSWORD }}" `
-var="xcode_install_storage_url=${{ secrets.xcode_install_storage_url }}" `
-var="xcode_install_sas=${{ secrets.xcode_install_sas }}" `
-var="github_api_pat=${{ secrets.GH_FEED_TOKEN }}" `
-var="build_id=${{ env.VM_NAME }}" `
-var="baseimage_name=${{ inputs.base_image_name }}" `
-color=false `
${{ inputs.template_path }} `
| Where-Object {
#Filter sensitive data from Packer logs
$currentString = $_
$sensitiveString = $SensitiveData | Where-Object { $currentString -match $_ }
$sensitiveString -eq $null
}
working-directory: images/macos
env:
PACKER_LOG: 1
PACKER_LOG_PATH: ${{ runner.temp }}/packer-log.txt
- name: Prepare artifact
shell: bash
run: |
echo "Preparing artifact directory"
mkdir -p ${{ runner.temp }}/artifacts
echo "Copy image output files"
cp -R "images/image-output/software-report/." "${{ runner.temp }}/artifacts"
echo "Put VM name to 'VM_Done_Name' file"
echo "${{ env.VM_NAME }}" > "${{ runner.temp }}/artifacts/VM_Done_Name"
- name: Print markdown software report
run: |
Get-Content "${{ runner.temp }}/artifacts/systeminfo.md"
- name: Print json software report
run: |
Get-Content "${{ runner.temp }}/artifacts/systeminfo.json"
- name: Publish Artifacts
uses: actions/upload-artifact@v3
with:
name: Built_VM_Artifacts
path: ${{ runner.temp }}/artifacts/
- name: Print provisioners duration
run: |
./images.CI/measure-provisioners-duration.ps1 `
-PackerLogPath "${{ runner.temp }}/packer-log.txt" `
-PrintTopNLongest 25
- name: Move vm to cold storage and clear datastore tag
if: ${{ always() }}
run: |
./images.CI/macos/move-vm.ps1 `
-VMName "${{ env.VM_NAME }}" `
-TargetDataStore "${{ inputs.target_datastore }}" `
-VIServer "${{ secrets.VISERVER_V2 }}" `
-VIUserName "${{ secrets.VI_USER_NAME }}" `
-VIPassword "${{ secrets.VI_PASSWORD }}" `
-JobStatus "${{ job.status }}"
- name: Set VM size
run: |
$cpuCount = 3
$coresPerSocketCount = 3
$memory = 14336
./images.CI/macos/set-vm-size.ps1 `
-VMName "${{ env.VM_NAME }}" `
-CpuCount "$cpuCount" `
-CoresPerSocketCount "$coresPerSocketCount" `
-Memory "$memory" `
-VIServer "${{ secrets.VISERVER_V2 }}" `
-VIUserName "${{ secrets.VI_USER_NAME }}" `
-VIPassword "${{ secrets.VI_PASSWORD }}"
- name: Destroy VM (if build canceled only)
if: ${{ cancelled() }}
run: |
./images.CI/macos/destroy-vm.ps1 `
-VMName "${{ env.VM_NAME }}" `
-VIServer "${{ secrets.VISERVER_V2 }}" `
-VIUserName "${{ secrets.VI_USER_NAME }}" `
-VIPassword "${{ secrets.VI_PASSWORD }}"

View File

@@ -1,24 +0,0 @@
run-name: macOS-11_unstable.${{ github.run_id }}.${{ github.run_attempt }}
on:
workflow_dispatch:
inputs:
CUSTOM_REPOSITORY:
description: 'Custom repository (owner/repo)'
required: false
CUSTOM_REPOSITORY_COMMIT_HASH:
description: 'Commit hash'
required: false
jobs:
macOS_11:
if: (github.event_name == 'workflow_dispatch') || (github.event_name == 'schedule')
name: macOS-11_unstable.${{ github.run_id }}.${{ github.run_attempt }}
uses: ./.github/workflows/macos-generation.yml
with:
image_label: 'macOS Big Sur'
base_image_name: 'clean-macOS-11-380Gb-runner'
template_path: 'templates/macOS-11.json'
target_datastore: 'ds-image'
custom_repo: ${{ github.event.inputs.CUSTOM_REPOSITORY }}
custom_repo_commit_hash: ${{ github.event.inputs.CUSTOM_REPOSITORY_COMMIT_HASH }}
secrets: inherit

View File

@@ -1,24 +0,0 @@
run-name: macOS-12_unstable.${{ github.run_id }}.${{ github.run_attempt }}
on:
workflow_dispatch:
inputs:
CUSTOM_REPOSITORY:
description: 'Custom repository (owner/repo)'
required: false
CUSTOM_REPOSITORY_COMMIT_HASH:
description: 'Commit hash'
required: false
jobs:
macOS_12:
if: (github.event_name == 'workflow_dispatch') || (github.event_name == 'schedule')
name: macOS-12_unstable.${{ github.run_id }}.${{ github.run_attempt }}
uses: ./.github/workflows/macos-generation.yml
with:
image_label: 'macOS Monterey'
base_image_name: 'clean-macOS-12-380Gb-runner'
template_path: 'templates/macOS-12.json'
target_datastore: 'ds-image'
custom_repo: ${{ github.event.inputs.CUSTOM_REPOSITORY }}
custom_repo_commit_hash: ${{ github.event.inputs.CUSTOM_REPOSITORY_COMMIT_HASH }}
secrets: inherit

View File

@@ -1,135 +0,0 @@
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: |
$ResourcesNamePrefix = ${{ github.run_id }} % [System.UInt32]::MaxValue
./images.CI/linux-and-win/build-image.ps1 `
-TemplatePath ${{ env.TemplatePath }} `
-ClientId ${{ secrets.CLIENT_ID }} `
-ClientSecret ${{ secrets.CLIENT_SECRET }} `
-Location ${{ secrets.AZURE_LOCATION }} `
-ResourcesNamePrefix $ResourcesNamePrefix `
-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: |
$BuildId = ${{ github.run_id }} % [System.UInt32]::MaxValue
./images.CI/linux-and-win/create-release.ps1 `
-BuildId $BuildId `
-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 }}

View File

@@ -1,21 +0,0 @@
run-name: Ubuntu20.04 - ${{ (github.event.pull_request.title || 'scheduled/manual run') }}
on:
workflow_dispatch:
inputs:
CUSTOM_REPOSITORY:
description: 'Custom repository (owner/repo)'
required: false
CUSTOM_REPOSITORY_COMMIT_HASH:
description: 'Commit hash'
required: false
jobs:
Ubuntu_2004:
if: (github.event_name == 'workflow_dispatch') || (github.event_name == 'schedule')
uses: ./.github/workflows/ubuntu-win-generation.yml
with:
image_name: 'ubuntu2004'
image_readme_name: 'Ubuntu2004-Readme.md'
custom_repo: ${{ github.event.inputs.CUSTOM_REPOSITORY }}
custom_repo_commit_hash: ${{ github.event.inputs.CUSTOM_REPOSITORY_COMMIT_HASH }}
secrets: inherit

View File

@@ -1,21 +0,0 @@
run-name: Ubuntu22.04 - ${{ (github.event.pull_request.title || 'scheduled/manual run') }}
on:
workflow_dispatch:
inputs:
CUSTOM_REPOSITORY:
description: 'Custom repository (owner/repo)'
required: false
CUSTOM_REPOSITORY_COMMIT_HASH:
description: 'Commit hash'
required: false
jobs:
Ubuntu_2204:
if: (github.event_name == 'workflow_dispatch') || (github.event_name == 'schedule')
uses: ./.github/workflows/ubuntu-win-generation.yml
with:
image_name: 'ubuntu2204'
image_readme_name: 'Ubuntu2204-Readme.md'
custom_repo: ${{ github.event.inputs.CUSTOM_REPOSITORY }}
custom_repo_commit_hash: ${{ github.event.inputs.CUSTOM_REPOSITORY_COMMIT_HASH }}
secrets: inherit

View File

@@ -1,21 +0,0 @@
run-name: Windows 2019 - ${{ (github.event.pull_request.title || 'scheduled/manual run') }}
on:
workflow_dispatch:
inputs:
CUSTOM_REPOSITORY:
description: 'Custom repository (owner/repo)'
required: false
CUSTOM_REPOSITORY_COMMIT_HASH:
description: 'Commit hash'
required: false
jobs:
Windows_2019:
if: (github.event_name == 'workflow_dispatch') || (github.event_name == 'schedule')
uses: ./.github/workflows/ubuntu-win-generation.yml
with:
image_name: 'windows2019'
image_readme_name: 'Windows2019-Readme.md'
custom_repo: ${{ github.event.inputs.CUSTOM_REPOSITORY }}
custom_repo_commit_hash: ${{ github.event.inputs.CUSTOM_REPOSITORY_COMMIT_HASH }}
secrets: inherit

View File

@@ -1,21 +0,0 @@
run-name: Windows 2022 - ${{ (github.event.pull_request.title || 'scheduled/manual run') }}
on:
workflow_dispatch:
inputs:
CUSTOM_REPOSITORY:
description: 'Custom repository (owner/repo)'
required: false
CUSTOM_REPOSITORY_COMMIT_HASH:
description: 'Commit hash'
required: false
jobs:
Windows_2022:
if: (github.event_name == 'workflow_dispatch') || (github.event_name == 'schedule')
uses: ./.github/workflows/ubuntu-win-generation.yml
with:
image_name: 'windows2022'
image_readme_name: 'Windows2022-Readme.md'
custom_repo: ${{ github.event.inputs.CUSTOM_REPOSITORY }}
custom_repo_commit_hash: ${{ github.event.inputs.CUSTOM_REPOSITORY_COMMIT_HASH }}
secrets: inherit