Always cancel in-progress workflows on new commits

The current ``github.head_ref || github.run_id`` syntax only cancels
in-progress GitHub Actions runs triggered by pull requests, as
``head_ref`` is only defined for pull requests, and ``run_id`` is
always unique. This changes to using ``ref``, which is the name of
the branch or tag linked to the commit, meaning that in-progress jobs
will be cancelled on pushes to a branch.
This commit is contained in:
Adam Turner 2023-02-15 03:35:15 +00:00
parent ff852bc7c3
commit 607908924c
5 changed files with 5 additions and 5 deletions

View File

@ -6,7 +6,7 @@ permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:

View File

@ -6,7 +6,7 @@ permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:

View File

@ -6,7 +6,7 @@ permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:

View File

@ -6,7 +6,7 @@ permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:

View File

@ -6,7 +6,7 @@ permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs: