Add GitHub ci workflows (#8464)

This commit is contained in:
Shamil Mubarakshin
2023-10-06 15:51:08 +02:00
committed by GitHub
parent c6820d1a5b
commit 23ff0d7468
6 changed files with 175 additions and 0 deletions

48
.github/workflows/ci-cleanup.yml vendored Normal file
View File

@@ -0,0 +1,48 @@
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

@@ -0,0 +1,47 @@
name: Trigger Build workflow
on:
workflow_call:
inputs:
image_type:
required: true
type: string
defaults:
run:
shell: pwsh
jobs:
trigger-workflow:
runs-on: ubuntu-latest
steps:
- name: Trigger Build workflow
env:
CI_PR_TOKEN: ${{ secrets.CI_PR_TOKEN }}
PR_TITLE: ${{ github.event.pull_request.title }}
CI_PR: ${{ secrets.CI_REPO }}
run: |
$headers = @{
Authorization="Bearer $env:CI_PR_TOKEN"
}
# Private repository for builds
$apiRepoUrl = "https://api.github.com/repos/$env:CI_PR"
$eventType = "trigger-${{ inputs.image_type }}-build"
$body = @{
event_type = $eventType;
client_payload = @{
pr_title = "$env:PR_TITLE"
custom_repo = "${{ github.event.pull_request.head.repo.full_name }}"
custom_repo_commit_hash = "${{ github.event.pull_request.head.sha }}"
}
}
$bodyString = $body | ConvertTo-Json
try {
Invoke-WebRequest -Uri "$apiRepoUrl/dispatches" -Method Post -Headers $headers -Body $bodyString | Out-Null
} catch {
throw "$($_.exception[0].message)"
}

20
.github/workflows/ubuntu2004.yml vendored Normal file
View File

@@ -0,0 +1,20 @@
name: Trigger Ubuntu20.04 CI
run-name: Ubuntu20.04 - ${{ github.event.pull_request.title }}
on:
pull_request_target:
types: labeled
paths:
- 'images/linux/**'
defaults:
run:
shell: pwsh
jobs:
Ubuntu_2004:
if: contains(github.event.pull_request.labels.*.name, 'CI ubuntu-all') || contains(github.event.pull_request.labels.*.name, 'CI ubuntu-2004')
uses: ./.github/workflows/trigger-ubuntu-win-build.yml
with:
image_type: 'ubuntu2004'
secrets: inherit

20
.github/workflows/ubuntu2204.yml vendored Normal file
View File

@@ -0,0 +1,20 @@
name: Trigger Ubuntu22.04 CI
run-name: Ubuntu22.04 - ${{ github.event.pull_request.title }}
on:
pull_request_target:
types: labeled
paths:
- 'images/linux/**'
defaults:
run:
shell: pwsh
jobs:
Ubuntu_2204:
if: contains(github.event.pull_request.labels.*.name, 'CI ubuntu-all') || contains(github.event.pull_request.labels.*.name, 'CI ubuntu-2204')
uses: ./.github/workflows/trigger-ubuntu-win-build.yml
with:
image_type: 'ubuntu2204'
secrets: inherit

20
.github/workflows/windows2019.yml vendored Normal file
View File

@@ -0,0 +1,20 @@
name: Trigger Windows19 CI
run-name: Windows2019 - ${{ github.event.pull_request.title }}
on:
pull_request_target:
types: labeled
paths:
- 'images/win/**'
defaults:
run:
shell: pwsh
jobs:
Windows_2019:
if: contains(github.event.pull_request.labels.*.name, 'CI windows-all') || contains(github.event.pull_request.labels.*.name, 'CI windows-2019')
uses: ./.github/workflows/trigger-ubuntu-win-build.yml
with:
image_type: 'windows2019'
secrets: inherit

20
.github/workflows/windows2022.yml vendored Normal file
View File

@@ -0,0 +1,20 @@
name: Trigger Windows22 CI
run-name: Windows2022 - ${{ github.event.pull_request.title }}
on:
pull_request_target:
types: labeled
paths:
- 'images/win/**'
defaults:
run:
shell: pwsh
jobs:
Windows_2022:
if: contains(github.event.pull_request.labels.*.name, 'CI windows-all') || contains(github.event.pull_request.labels.*.name, 'CI windows-2022')
uses: ./.github/workflows/trigger-ubuntu-win-build.yml
with:
image_type: 'windows2022'
secrets: inherit