小智 7
gh 运行列表 + powershell:
gh run list --limit 5000 --json status,databaseId -q ".[] | select (.status == \`"queued\`" ) | .databaseId" | ForEach-Object -Process { gh run cancel $_ }
Run Code Online (Sandbox Code Playgroud)
获取前 5000 个工作流程,按“status”==“queued”对其进行过滤,并将其传递给“gh run cancel”
您可以使用Github Actions API列出工作流程运行和取消工作流程运行。
queued或in_progress要运行下面的脚本,您将需要带有 repo 的个人访问令牌scope:
token=YOUR_TOKEN
repo=your_user/your_repo
ids=$(curl -s -H "Authorization: token $token" \
https://api.github.com/repos/$repo/actions/runs | \
jq '.workflow_runs[] | select([.status] | inside(["in_progress", "queued"])) | .id')
set -- $ids
for i; do curl \
-H "Authorization: token $token" \
-X POST "https://api.github.com/repos/$repo/actions/runs/$i/cancel"; done
Run Code Online (Sandbox Code Playgroud)
macOS oneliner(受到其他答案的启发):
for id in $(gh run list --limit 5000 --jq ".[] | select (.status == \"queued\" ) | .databaseId" --json databaseId,status); do gh run cancel $id; done
# List 5000 runs, filters them by "status == queued", and passes them to "gh run cancel"
Run Code Online (Sandbox Code Playgroud)
笔记:
brew install gh首先通过and安装 gh cligh auth login| 归档时间: |
|
| 查看次数: |
4727 次 |
| 最近记录: |