potiuk commented on a change in pull request #12625:
URL: https://github.com/apache/superset/pull/12625#discussion_r565919009



##########
File path: .github/workflows/cancel_duplicates.yml
##########
@@ -1,25 +1,43 @@
 name: Cancel Duplicates
 on:
   workflow_run:
-    workflows: ["CI"]
-    types: ["requested"]
+    workflows:
+      - "Miscellaneous"
+    types:
+      - requested
 
 jobs:
-  cancel-duplicate-workflow-runs:
-    name: "Cancel duplicate workflow runs"
-    runs-on: ubuntu-latest
+  cancel-duplicate-runs:
+    name: Cancel duplicate workflow runs
+    runs-on: ubuntu-20.04
     steps:
+      - name: Check number of queued tasks
+        id: check_queued
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+          GITHUB_REPO: ${{ github.repository }}
+        run: |
+          get_count() {
+            echo $(curl -s -H "Authorization: token $GITHUB_TOKEN" \
+                    
"https://api.github.com/repos/$GITHUB_REPO/actions/runs?status=$1"; | \
+                    jq ".total_count")
+          }
+          count=$(( `get_count queued` + `get_count in_progress` ))
+          echo "Found $count unfinished jobs."
+          echo "::set-output name=count::$count"
+
       - name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
+        if: steps.check_queued.outputs.count >= 20
         uses: actions/checkout@v2
         with:
           persist-credentials: false
           submodules: recursive
-      - uses: ./.github/actions/cancel-workflow-runs/
-        name: "Cancel duplicate workflow runs"
+
+      - name: Cancel duplicate workflow runs
+        if: steps.check_queued.outputs.count >= 20
+        uses: ./.github/actions/cancel-workflow-runs
         with:
-          cancelMode: duplicates
-          cancelFutureDuplicates: true
-          token: ${{ secrets.GITHUB_TOKEN }}
+          cancelMode: allDuplicates
           sourceRunId: ${{ github.event.workflow_run.id }}
-          notifyPRCancel: true
-          skipEventTypes: '["push", "pull_request", "pull_request_target"]'
+          token: ${{ secrets.GITHUB_TOKEN }}
+          notifyPRCancel: false

Review comment:
       I believe since you are trying to cancel other workflows, you need to 
specify also 
   `workflowFileName` parameter and specify the workflow run file name that you 
want to cancel.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to