-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathCleanWorkflows.ps1
35 lines (25 loc) · 919 Bytes
/
CleanWorkflows.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
$USER = "AntonioFalcaoJr"
$REPO = "EventualShop"
Write-Output "Getting workflows for $USER/$REPO"
$url = "/repos/$USER/$REPO/actions/workflows"
$json = gh api $url | ConvertFrom-Json
Write-Output "Found $($json.total_count) workflows"
$json.workflows | ForEach-Object -Parallel {
$USER = $using:USER
$REPO = $using:REPO
$workflowId = $_.id
$workflowName = $_.name
Write-Output "Getting runs for workflow $workflowName, id $workflowId"
$url = "/repos/$USER/$REPO/actions/workflows/$workflowId/runs"
$json = gh api -X GET $url
$runs = $json | ConvertFrom-Json
Write-Output "Found $($runs.total_count) runs"
$runs.workflow_runs | ForEach-Object -Parallel {
$USER = $using:USER
$REPO = $using:REPO
$runId = $_.id
Write-Output "Deleting run $runId"
$url = "/repos/$USER/$REPO/actions/runs/$runId"
gh api -X DELETE $url
}
}