Skip to content

Commit dd43959

Browse files
jrfnlgrogy
authored andcommitted
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 1c346b8 commit dd43959

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

Diff for: .github/workflows/release.yml

+6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ on:
77
# Allow manually triggering the workflow.
88
workflow_dispatch:
99

10+
# Cancels all previous workflow runs for the same branch that have not yet completed.
11+
concurrency:
12+
# The concurrency group contains the workflow name and the branch name.
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
1016
jobs:
1117
bundle:
1218
# Don't run on forks.

Diff for: .github/workflows/test.yml

+6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ on:
99
# Allow manually triggering the workflow.
1010
workflow_dispatch:
1111

12+
# Cancels all previous workflow runs for the same branch that have not yet completed.
13+
concurrency:
14+
# The concurrency group contains the workflow name and the branch name.
15+
group: ${{ github.workflow }}-${{ github.ref }}
16+
cancel-in-progress: true
17+
1218
jobs:
1319
lint:
1420
name: Run style linter

0 commit comments

Comments
 (0)