Skip to content

Commit ec8fc2d

Browse files
committed
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
1 parent 6c0047e commit ec8fc2d

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

.github/workflows/check-cs.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ on:
1010
# Allow manually triggering the workflow.
1111
workflow_dispatch:
1212

13+
# Cancels all previous workflow runs for the same branch that have not yet completed.
14+
concurrency:
15+
# The concurrency group contains the workflow name and the branch name.
16+
group: ${{ github.workflow }}-${{ github.ref }}
17+
cancel-in-progress: true
18+
1319
jobs:
1420
fix-style:
1521
name: Fix Code Style

.github/workflows/run-tests.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ on:
1010
# Allow manually triggering the workflow.
1111
workflow_dispatch:
1212

13+
# Cancels all previous workflow runs for the same branch that have not yet completed.
14+
concurrency:
15+
# The concurrency group contains the workflow name and the branch name.
16+
group: ${{ github.workflow }}-${{ github.ref }}
17+
cancel-in-progress: true
18+
1319
jobs:
1420
php-tests:
1521
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)