feat(actions): add force-cancel workflow run API - #38756
Draft
Zettat123 wants to merge 9 commits into
Draft
Conversation
lunny
approved these changes
Aug 3, 2026
bircni
approved these changes
Aug 3, 2026
Contributor
|
Related to Fix allow cancelling runs without running jobs - #35842 ? |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new Actions REST API endpoint to force-cancel workflow runs (POST /repos/{owner}/{repo}/actions/runs/{run}/force-cancel), mirroring GitHub’s behavior by bypassing the graceful runner cancellation handshake and immediately stopping running tasks, while keeping permissions and responses aligned with the existing /cancel endpoint.
Changes:
- Introduces
ForceCancelWorkflowRunAPI route/handler and wires it into the v1 router. - Extends the cancellation pipeline with a “force” mode (
ForceCancelRun→ForceCancelJobs), causing running tasks to be stopped ascancelledinstead of entering thecancellinghandshake. - Adds model- and integration-level tests for force-cancel behavior and updates generated Swagger/OpenAPI specs.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/integration/api_actions_run_test.go | Adds an integration test validating force-cancel behavior vs normal cancel handshake. |
| templates/swagger/v1-swagger.generated.json | Documents the new force-cancel endpoint in Swagger v2 output. |
| templates/swagger/v1-openapi3.generated.json | Documents the new force-cancel endpoint in OpenAPI v3 output. |
| services/actions/cancel.go | Adds ForceCancelRun and factors shared logic into cancelRun(..., force). |
| routers/api/v1/repo/actions_run.go | Adds ForceCancelWorkflowRun handler and shares logic with CancelWorkflowRun. |
| routers/api/v1/api.go | Registers the /force-cancel route under workflow run endpoints. |
| models/actions/run_job.go | Adds ForceCancelJobs and threads a force flag into job cancellation to stop tasks immediately. |
| models/actions/run_job_test.go | Adds unit tests for force-cancelling running and already-cancelling tasks. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
wxiaoguang
marked this pull request as draft
August 3, 2026 12:28
Contributor
Waiting for the answer to this question. |
Contributor
Author
Contributor
Author
wxiaoguang
marked this pull request as ready for review
August 4, 2026 04:47
Zettat123
marked this pull request as draft
August 4, 2026 15:46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add
POST /repos/{owner}/{repo}/actions/runs/{run}/force-cancel, the counterpart ofGitHub's force-cancel endpoint.
It cancels a run like
POST .../cancel, but bypasses the graceful cancelling handshake with the runner and stops running tasks immediately.Permissions and responses match the
/cancelendpoint.References: