feat(github): auto cancel previous continuous-integration.yml run when a PR is updated

This commit is contained in:
rudy
2022-08-31 10:14:51 +02:00
committed by Ayoub Benaissa
parent b0743a9924
commit 4a6b9148d1
2 changed files with 18 additions and 4 deletions

14
.github/workflows/auto-cancel.yml vendored Normal file
View File

@@ -0,0 +1,14 @@
# https://github.com/styfle/cancel-workflow-action#user-content-advanced-canceling-other-workflows
name: Auto-cancel-outdated PR
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
cancel:
name: Auto-cancel-outdated PR
runs-on: ubuntu-latest
steps:
- uses: styfle/cancel-workflow-action@0.10.0
with:
workflow_id: all
access_token: ${{ github.token }}

View File

@@ -56,10 +56,10 @@ jobs:
strategy:
matrix:
compiler: [gcc7, latest]
# We want to always run the tests, but after the docker image build job.
# We want to always run the tests unless cancelled, but after the docker image build job.
# If there is no new build then we use the old image, else we use the new image.
# The latest compiler job isn't using the built image, so it suffers the dependance of the gcc7 job.
if: ${{ always() }}
if: ${{ !cancelled() }}
needs: [BuildAndPushDockerImages]
steps:
# Free 4Gb of workspace
@@ -307,9 +307,9 @@ jobs:
BuildAndTestDF:
runs-on: ubuntu-latest
# We want to always run the tests, but after the docker image build job.
# We want to always run the tests unless cancelled, but after the docker image build job.
# If there is no new build then we use the old image, else we use the new image.
if: ${{ always() }}
if: ${{ !cancelled() }}
needs: [BuildAndPushDockerImages]
steps:
# A SSH private key is required as some dependencies are from private repos