答案 0 :(得分:1)
您可以使用Github Actions API列出工作流程运行并取消工作流程运行。
queued
或in_progress
的工作流运行的ID 要运行以下脚本,您将需要一个personnal access token和仓库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
答案 1 :(得分:0)
我创建了small script来手动取消给定分支或请求请求的所有未完成的作业:
Example:
# Set up
export GITHUB_TOKEN=394ba3b48494ab8f930fbc93
export GITHUB_REPOSITORY=apache/incubator-superset
# Cancel previous jobs for a PR
./cancel_github_workflows.py 1042
# Cancel previous jobs for a branch
./cancel_github_workflows.py my-branch
# Cancel all jobs including the last ones, this is useful
# when you have closed a PR or deleted a branch and want
# to cancel all its jobs.
./cancel_github_workflows.py 1024 --include-last