From 537c0e657aa6593aa09fee3a5b2e3a12a6180ad6 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 25 Mar 2026 13:26:34 +0100 Subject: [PATCH] GH Actions: auto-cancel previous jobs for same branch When the same branch is pushed again, any still running builds for the same branch should be stopped in favour of starting the build for the newly pushed version of the branch. The `test` workflow did not apply this best practice. Fixed now. Includes minor formatting improvement for the `on` key. Refs: * https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#concurrency --- .github/workflows/tests.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0f225a0..a2d4bca 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,5 +1,17 @@ name: Tests -on: [push, pull_request, workflow_dispatch] + +on: + push: + pull_request: + # Allow manually triggering the workflow. + workflow_dispatch: + +# Cancels all previous workflow runs for the same branch that have not yet completed. +concurrency: + # The concurrency group contains the workflow name and the branch name. + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: test: runs-on: ubuntu-latest