test: cancel workflows on same branch when new commit is added (#9771)
This is pretty common when working through PRs and ends up causing tons of in-flight GitHub Actions workflows running because they aren't currently canceled when a new commit is added. This will cancel previous runs if a new commit is added on a branch (which is the behavior we had on CircleCI).
Gus Eggert committed
Mar 30, 2023 at 07:58 UTC
ebdca5cf0221f0408ef5f504448f0c6e89fb9cf8
8 files changed
+32
.github/workflows/build.yml
+4
@@ -10,6 +10,10 @@ on:
10
env:
11
GO_VERSION: 1.19.1
12
13
+concurrency:
14
+ group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event_name == 'push' && github.sha || github.ref }}
15
+ cancel-in-progress: true
16
+
17
jobs:
18
interop-prep:
19
if: github.repository == 'ipfs/kubo' || github.event_name == 'workflow_dispatch'
.github/workflows/codeql-analysis.yml
+4
@@ -15,6 +15,10 @@ permissions:
15
contents: read # to fetch code (actions/checkout)
16
security-events: write # (github/codeql-action/autobuild)
17
18
+concurrency:
19
+ group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event_name == 'push' && github.sha || github.ref }}
20
+ cancel-in-progress: true
21
+
22
jobs:
23
codeql:
24
if: github.repository == 'ipfs/kubo' || github.event_name == 'workflow_dispatch'
.github/workflows/docker-build.yml
+4
@@ -7,6 +7,10 @@ on:
7
branches:
8
- 'master'
9
10
+concurrency:
11
+ group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event_name == 'push' && github.sha || github.ref }}
12
+ cancel-in-progress: true
13
+
14
jobs:
15
docker-build:
16
if: github.repository == 'ipfs/kubo' || github.event_name == 'workflow_dispatch'
.github/workflows/gobuild.yml
+4
@@ -7,6 +7,10 @@ on:
7
branches:
8
- 'master'
9
10
+concurrency:
11
+ group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event_name == 'push' && github.sha || github.ref }}
12
+ cancel-in-progress: true
13
+
14
jobs:
15
go-build-runner:
16
if: github.repository == 'ipfs/kubo' || github.event_name == 'workflow_dispatch'
.github/workflows/golang-analysis.yml
+4
@@ -10,6 +10,10 @@ on:
10
permissions:
11
contents: read # to fetch code (actions/checkout)
12
13
+concurrency:
14
+ group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event_name == 'push' && github.sha || github.ref }}
15
+ cancel-in-progress: true
16
+
17
jobs:
18
go-check:
19
if: github.repository == 'ipfs/kubo' || github.event_name == 'workflow_dispatch'
.github/workflows/golint.yml
+4
@@ -7,6 +7,10 @@ on:
7
branches:
8
- 'master'
9
10
+concurrency:
11
+ group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event_name == 'push' && github.sha || github.ref }}
12
+ cancel-in-progress: true
13
+
14
jobs:
15
go-lint:
16
if: github.repository == 'ipfs/kubo' || github.event_name == 'workflow_dispatch'
.github/workflows/gotest.yml
+4
@@ -7,6 +7,10 @@ on:
7
branches:
8
- 'master'
9
10
+concurrency:
11
+ group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event_name == 'push' && github.sha || github.ref }}
12
+ cancel-in-progress: true
13
+
14
jobs:
15
go-test:
16
if: github.repository == 'ipfs/kubo' || github.event_name == 'workflow_dispatch'
.github/workflows/sharness.yml
+4
@@ -7,6 +7,10 @@ on:
7
branches:
8
- 'master'
9
10
+concurrency:
11
+ group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event_name == 'push' && github.sha || github.ref }}
12
+ cancel-in-progress: true
13
+
14
jobs:
15
sharness-runner:
16
if: github.repository == 'ipfs/kubo' || github.event_name == 'workflow_dispatch'