Repository navigation
Cancel CI runs of merged and closed pull requests - #5748
Merged
Merged
Conversation
The concurrency groups cancel superseded runs when a pull request gets new commits, but the runs of its last commit keep going after it is merged or closed and hold up the queue of the open pull requests. A new workflow on pull_request_target/closed cancels all unfinished pull request runs of the head commit. It never checks out the pull request's code. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
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.
Summary
Every workflow already has a concurrency group, so a new commit on a pull request cancels its older runs, and there is at most one run per workflow and branch. But once a pull request is merged or closed, the runs of its last commit keep going. With many open pull requests this holds up the queue for hours. For example, all nine runs of #5745 were still queued after it had been merged.
This adds
.github/workflows/cancel_closed_pr_runs.yml:pull_request_target/closed(which includes merged), so the token can also cancel runs of pull requests from forksactions: writeonly; it never checks out or runs pull request code, it only calls the APIpull_requestorpull_request_target. Push runs are excluded because a branch that is pushed todevelopdirectly shares the head SHA with the push runs there.As a one-off cleanup I also cancelled 111 stale queued runs by hand (merged/closed pull requests and superseded commits of open ones).
Breaking changes
None. This only changes CI; the library and its public API are unchanged.
Written by Claude Code.
🤖 Generated with Claude Code