问题:
- 失败的拉取请求将增加失败运行的列表。此列表可能会变得难以管理,用户界面一次只允许您删除1次失败的运行
https://github.com/{owner}/{repo}/actions
这是通过使用githubapi文档帮助我的脚本。
$token = 'asdlf234lk23jkl2j65tl1234lkj_PAT'
$owner = 'bob'
$repo = 'coolToolRepoName'
$body = [PSCustomObject]@{
status = 'failure'
per_page = 10
} | ConvertTo-Hashtable
$header = [PSCustomObject]@{
Authorization = "token $token"
} | ConvertTo-Hashtable
$failures = Invoke-RestMethod https://api.github.com/repos/$owner/$repo/actions/runs -Headers $header -Body $body -ContentType 'application/json'
foreach($rec in $failures.workflow_runs){
Write-Host deleting $rec.id
Invoke-RestMethod -Method delete -Uri "https://api.github.com/repos/$owner/$repo/actions/runs/$($rec.id)" -Headers $header
}