mirror of
https://github.com/apache/superset.git
synced 2024-09-12 00:29:39 -04:00
44 lines
1.3 KiB
YAML
44 lines
1.3 KiB
YAML
name: Cancel Duplicates
|
|
on:
|
|
workflow_run:
|
|
workflows:
|
|
- "Miscellaneous"
|
|
types:
|
|
- requested
|
|
|
|
jobs:
|
|
cancel-duplicate-runs:
|
|
name: Cancel duplicate workflow runs
|
|
runs-on: ubuntu-20.04
|
|
permissions:
|
|
actions: write
|
|
contents: read
|
|
steps:
|
|
- name: Check number of queued tasks
|
|
id: check_queued
|
|
env:
|
|
GITHUB_TOKEN: ${{ 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@v3
|
|
|
|
- name: Cancel duplicate workflow runs
|
|
if: steps.check_queued.outputs.count >= 20
|
|
env:
|
|
GITHUB_TOKEN: ${{ github.token }}
|
|
GITHUB_REPOSITORY: ${{ github.repository }}
|
|
run: |
|
|
pip install click requests typing_extensions python-dateutil
|
|
python ./scripts/cancel_github_workflows.py
|