From d5a11eb076daa0e83809c68dd21fb32879eba5a2 Mon Sep 17 00:00:00 2001 From: Kris Austin Date: Sun, 11 Oct 2026 16:32:32 -0500 Subject: [PATCH] ci: cancel Build all runs of closed pull requests (#16380) --- .github/workflows/build_all.yml | 4 +++- .github/workflows/cancel_closed_pr_builds.yml | 21 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/cancel_closed_pr_builds.yml diff --git a/.github/workflows/build_all.yml b/.github/workflows/build_all.yml index 081cfd22cc..22790fb1e8 100644 --- a/.github/workflows/build_all.yml +++ b/.github/workflows/build_all.yml @@ -57,7 +57,9 @@ on: default: false concurrency: - group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref }} + # cancel_closed_pr_builds.yml joins this group by name, so update that file + # with any change here. + group: build-all-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref }} # Pushes don't cancel a running build, because only a finished branch build # saves caches every pull request can restore. cancel-in-progress: ${{ github.event_name == 'pull_request' }} diff --git a/.github/workflows/cancel_closed_pr_builds.yml b/.github/workflows/cancel_closed_pr_builds.yml new file mode 100644 index 0000000000..c0c9c52fee --- /dev/null +++ b/.github/workflows/cancel_closed_pr_builds.yml @@ -0,0 +1,21 @@ +name: Cancel builds of closed pull requests + +on: + # pull_request_target needs no approval for first-time contributors and must never + # check out pull request code. + pull_request_target: + types: + - closed + +permissions: {} + +jobs: + cancel: + # Matches the concurrency group in build_all.yml, so joining it cancels the pull + # request's unfinished Build all run. + concurrency: + group: build-all-pull_request-${{ github.event.pull_request.number }} + cancel-in-progress: true + runs-on: ubuntu-latest + steps: + - run: echo "Joined concurrency group build-all-pull_request-${{ github.event.pull_request.number }}."