I did a misconfiguration with concurrency, initially in the root of my GitHub Actions workflow, and moved to a sub workflow (workflow_call).
Since, I have a workflow that is stuck with label:

I tried to cancel it with gh official CLI, response: gh: Cannot cancel a workflow run that is completed. (HTTP 409)

I also found this other workflow to be stuck, I also tried to cancel it with github api response : {}

Since all my following workflow are stuck.
According to GitHub, it is possible to force cancel a workflow using the API, but this doesn't work.
This is the more detailled force cancel workflow documentation.
How can I force stop a GitHub Actions workflow?
EDIT: apologies, I didn't read your original issue properly, you had:
According to GitHub, it is possible to force cancel a workflow using the API, but this doesn't work.
Leaving the rest below for posterity, but clearly this isn't an answer to your q.
If a workflow is stuck, or cannot be canceled for other reasons, there's now a new command (only available through the GH REST API) that forces the cancellation of a workflow: force-cancel.
Replace OWNER (or org) and REPO and RUN_ID with your current values.
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/OWNER/REPO/actions/runs/RUN_ID/force-cancel
Replace OWNER (or org) and REPO and RUN_ID with your current values.
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/OWNER/REPO/actions/runs/RUN_ID/force-cancel
EDIT: while this should just work, I currently have a situation where a run cannot be canceled using the front-end, and using this command, will return a 500 error.
Looks like the GitHub team didn't yet completely fix the issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With