From dd4395924dbcb5a6bcf005e5afcff84efd9b639b Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 1 Dec 2021 17:07:42 +0100 Subject: [PATCH] GH Actions: auto-cancel previous builds for same branch Previously, in Travis, when the same branch was pushed again and the "Auto cancellation" option on the "Settings" page had been turned on (as it was for most repos), any still running builds for the same branch would be stopped in favour of starting the build for the newly pushed version of the branch. To enable this behaviour in GH Actions, a `concurrency` configuration needs to be added to each workflow for which this should applied to. More than anything, this is a way to be kind to GitHub by not wasting resources which they so kindly provide to us for free. Refs: * https://github.blog/changelog/2021-04-19-github-actions-limit-workflow-run-or-job-concurrency/ * https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#concurrency --- .github/workflows/release.yml | 6 ++++++ .github/workflows/test.yml | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3980f1e..d53c045 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,6 +7,12 @@ on: # 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: bundle: # Don't run on forks. diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a0f2abc..e22bd05 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,6 +9,12 @@ on: # 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: lint: name: Run style linter