Skip to content

Commit

Permalink
.github: Cancel outdated PR and push workflows
Browse files Browse the repository at this point in the history
When updating a pull request, workflows associated with the previous
version continue to run. A way to prevent that and cancel outdated
workflows is to use concurrency groups.

This commit handles workflows triggered by pull requests and pushes.
We define each concurrency group such that they are unique to the
pull request (via PR number) if triggered by event pull_request or
to the commit (via SHA) if triggered by event push.

Signed-off-by: Paul Chaignon <paul@cilium.io>
  • Loading branch information
pchaigno committed May 20, 2021
1 parent ba8a3f7 commit 94744a8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: codeql

# Any change in triggers needs to be reflected in the concurrency group.
on:
push:
branches:
Expand All @@ -13,6 +14,10 @@ on:
schedule:
- cron: "45 7 * * 3"

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.after || 'scheduled' }}
cancel-in-progress: true

jobs:
analyze:
if: github.repository == 'cilium/hubble'
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
name: Run static checks and unit tests

# Any change in triggers needs to be reflected in the concurrency group.
on:
push:
branches:
Expand All @@ -8,6 +10,11 @@ on:
branches:
- master
- v*

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.after }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
Expand Down

0 comments on commit 94744a8

Please sign in to comment.