From 2cf3c5a708f2ee354cea97282a730527fc02b3e5 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Wed, 12 Aug 2026 01:49:28 +0200 Subject: [PATCH] fix(ci): cancel a closed PR's orchestrator without waiting for a runner The PR-close canceller had no concurrency group at all, so cancelling depended entirely on scripts/github/cancel/pull_request_runs.sh, which needs a runner before it can call the API. Runners were 20 minutes to 21 hours out, and run 31451265380 stayed alive that whole time. The canceller now joins the group entry-pr-change-orchestrate.yml renders for the same PR. GitHub clears the group when the run is created, before a runner is assigned, so the orchestrator dies immediately and the script becomes a backstop instead of the only path. The group spells pull_request out literally rather than interpolating github.event_name. This workflow is triggered by pull_request_target, so the interpolated form would join the twin the orchestrator's own job guards already skip on a same-repo PR and leave the working run untouched. A fork PR runs both twins; the pull_request_target one is still left to the script. The branch-delete sweep filtered runs by head_branch alone and shot this canceller mid-cancel. It now excludes the canceller's own path. Co-Authored-By: Claude Opus 5 (1M context) --- .github/workflows/entry-pr-closed-cancel-workflows.yml | 4 ++++ scripts/github/cancel/deleted_branch_runs.sh | 1 + 2 files changed, 5 insertions(+) diff --git a/.github/workflows/entry-pr-closed-cancel-workflows.yml b/.github/workflows/entry-pr-closed-cancel-workflows.yml index 9b486b6360..029568fc84 100644 --- a/.github/workflows/entry-pr-closed-cancel-workflows.yml +++ b/.github/workflows/entry-pr-closed-cancel-workflows.yml @@ -6,6 +6,10 @@ on: - closed - converted_to_draft +concurrency: + group: pr-ci-${{ github.repository }}-pull_request-pr-${{ github.event.pull_request.number }} + cancel-in-progress: true + permissions: actions: write contents: read diff --git a/scripts/github/cancel/deleted_branch_runs.sh b/scripts/github/cancel/deleted_branch_runs.sh index 346bd6aaf2..24abde67bc 100755 --- a/scripts/github/cancel/deleted_branch_runs.sh +++ b/scripts/github/cancel/deleted_branch_runs.sh @@ -27,6 +27,7 @@ cancel_runs_by_status() { "/repos/${REPOSITORY}/actions/runs?status=${status}&per_page=100" | jq -r --arg branch "${BRANCH}" ' .workflow_runs[] + | select(.path != ".github/workflows/entry-pr-closed-cancel-workflows.yml") | select( .head_branch == $branch or any(.pull_requests[]?; (.head.ref // "") == $branch)