mirror of
https://github.com/actions/runner-images.git
synced 2025-12-15 14:17:22 +00:00
Add PR_HEAD_REF env variable to ci-cleanup.yml (#8916)
* Add PR_HEAD_REF env variable to ci-cleanup.yml * Fix quotes around env var
This commit is contained in:
committed by
GitHub
parent
d86c4900fa
commit
d919a375b3
5
.github/workflows/ci-cleanup.yml
vendored
5
.github/workflows/ci-cleanup.yml
vendored
@@ -14,6 +14,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- env:
|
- env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
run: |
|
run: |
|
||||||
$startDate = Get-Date -UFormat %s
|
$startDate = Get-Date -UFormat %s
|
||||||
@@ -21,13 +22,13 @@ jobs:
|
|||||||
while ($true) {
|
while ($true) {
|
||||||
$continue = $false
|
$continue = $false
|
||||||
foreach ($wf in $workflows) {
|
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"
|
$skippedCommand = "gh run list --workflow ${wf}.yml --branch '$env:PR_HEAD_REF' --repo ${{ github.repository }} --status skipped --json databaseId"
|
||||||
$skippedIds = Invoke-Expression -Command $skippedCommand | ConvertFrom-Json | ForEach-Object { $_.databaseId }
|
$skippedIds = Invoke-Expression -Command $skippedCommand | ConvertFrom-Json | ForEach-Object { $_.databaseId }
|
||||||
$skippedIds | ForEach-Object {
|
$skippedIds | ForEach-Object {
|
||||||
$deleteCommand = "gh run delete --repo ${{ github.repository }} $_"
|
$deleteCommand = "gh run delete --repo ${{ github.repository }} $_"
|
||||||
Invoke-Expression -Command $deleteCommand
|
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 }}'"
|
$pendingCommand = "gh run list --workflow ${wf}.yml --branch '$env:PR_HEAD_REF' --repo ${{ github.repository }} --status requested --json databaseId --template '{{ . | len }}'"
|
||||||
$pending = Invoke-Expression -Command $pendingCommand
|
$pending = Invoke-Expression -Command $pendingCommand
|
||||||
if ($pending -gt 0) {
|
if ($pending -gt 0) {
|
||||||
Write-Host "Pending for ${wf}.yml: $pending run(s)"
|
Write-Host "Pending for ${wf}.yml: $pending run(s)"
|
||||||
|
|||||||
Reference in New Issue
Block a user