From 42077cb16007e033fc046136694ac0f9caf1ef27 Mon Sep 17 00:00:00 2001 From: luolanzone Date: Fri, 18 Jun 2021 01:45:41 +0800 Subject: [PATCH] add a workflow to cancel running workflow (#2279) add a cancel workflow so when there is a new PR or push previous workflow will be cancelled which will help to reduce concurrent github runner usage. refer to https://github.com/styfle/cancel-workflow-action#advanced-pull-requests-from-forks according to github page [here](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#workflow_run) this file has to be in default branch to take affect. Signed-off-by: Lan Luo --- .github/workflows/cancel_workflows.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .github/workflows/cancel_workflows.yml diff --git a/.github/workflows/cancel_workflows.yml b/.github/workflows/cancel_workflows.yml new file mode 100644 index 00000000000..050398a3726 --- /dev/null +++ b/.github/workflows/cancel_workflows.yml @@ -0,0 +1,15 @@ +name: Cancel Workflows +on: + workflow_run: + workflows: ["Go", "Golicense", "Kind", "Build and push latest image if needed", "Antrea upgrade"] + types: + - requested +jobs: + cancel: + name: Cancel workflows + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.event == 'pull_request' }} + steps: + - uses: styfle/cancel-workflow-action@0.9.0 + with: + workflow_id: ${{ github.event.workflow.id }}