From ca3d69c823a68195c8bf7d3da6b78a1c78a330d2 Mon Sep 17 00:00:00 2001 From: Kate Goldenring Date: Wed, 24 Mar 2021 15:59:30 -0700 Subject: [PATCH 1/2] use workflow_run trigger in cancel workflow --- .github/workflows/cancel-previous-pr-workflows.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cancel-previous-pr-workflows.yml b/.github/workflows/cancel-previous-pr-workflows.yml index bb41d9f44..9c3b1d95f 100644 --- a/.github/workflows/cancel-previous-pr-workflows.yml +++ b/.github/workflows/cancel-previous-pr-workflows.yml @@ -1,11 +1,14 @@ name: Cancel Previous PR Workflows on: - pull_request: - branches: [ main ] + workflow_run: + workflows: ["Dependencies autoupdate", "Build Agents", "Build Anomaly Detection App Container", "Build Controller", "Build ONVIF Broker (.NET)", "Build OPC UA Monitoring Broker", "Build OpenCV Base", "Build Production Rust Code", "Build Rust CrossBuild", "Build UDEV Broker", "Build Video Streaming App Container", "Build Webhook Configuration", "Check Rust", "Check versioning", "Helm", "Tarpaulin Code Coverage", "Test K3s, Kubernetes, and MicroK8s"] + types: + - requested jobs: cancel: runs-on: ubuntu-latest + if: (github.event.workflow_run.event != 'release') && (github.event.workflow_run.event != 'push') steps: - uses: styfle/cancel-workflow-action@0.8.0 with: - workflow_id: "auto-update-dependencies.yml, build-agent-container.yml, build-anomaly-detection-app-container.yml, build-controller-container.yml, build-onvif-video-broker-container.yml, build-opcua-monitoring-broker-container.yml, build-opencv-base-container.yml, build-rust-code.yml, build-rust-crossbuild-container.yml, build-udev-video-broker-container.yml, build-video-streaming-app-container.yml, build-webhook-configuration-container.yml, check-rust.yml, check-versioning.yml, run-helm.yml, run-tarpaulin.yml, run-test-cases.yml" \ No newline at end of file + workflow_id: ${{ github.event.workflow.id }} \ No newline at end of file From de804a60ef4c446df6167b19ea5e2a3cf6f93e44 Mon Sep 17 00:00:00 2001 From: Kate Goldenring Date: Thu, 25 Mar 2021 10:17:12 -0700 Subject: [PATCH 2/2] only run cancel workflow explicitly for pull_request events --- .github/workflows/cancel-previous-pr-workflows.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cancel-previous-pr-workflows.yml b/.github/workflows/cancel-previous-pr-workflows.yml index 9c3b1d95f..e5e5bc1d3 100644 --- a/.github/workflows/cancel-previous-pr-workflows.yml +++ b/.github/workflows/cancel-previous-pr-workflows.yml @@ -7,7 +7,7 @@ on: jobs: cancel: runs-on: ubuntu-latest - if: (github.event.workflow_run.event != 'release') && (github.event.workflow_run.event != 'push') + if: github.event.workflow_run.event == 'pull_request' steps: - uses: styfle/cancel-workflow-action@0.8.0 with: