From d502f2e36c4d8afe5010164610c132f45c6fea10 Mon Sep 17 00:00:00 2001 From: Jeongseok Lee Date: Sat, 30 Mar 2024 20:49:43 -0700 Subject: [PATCH] [ci] Remove workflow cleanup workflow --- .github/workflows/cleanup.yml | 19 ------------------ scripts/cleanup.sh | 36 ----------------------------------- 2 files changed, 55 deletions(-) delete mode 100644 .github/workflows/cleanup.yml delete mode 100755 scripts/cleanup.sh diff --git a/.github/workflows/cleanup.yml b/.github/workflows/cleanup.yml deleted file mode 100644 index c37ad77e9f66c..0000000000000 --- a/.github/workflows/cleanup.yml +++ /dev/null @@ -1,19 +0,0 @@ -# https://github.com/orgs/community/discussions/26256#discussioncomment-8756475 - -name: Remove Expired Workflows -on: - schedule: [{ cron: "0 3 * * 0" }] # Run every Sunday at 3 AM - workflow_dispatch: - -jobs: - clean: - name: Delete Expired Workflows - runs-on: ubuntu-latest - steps: - - name: Checkout Action Code - uses: actions/checkout@v4 - - - name: Run Delete Script - run: sh ./scripts/cleanup.sh dartsim dart - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/scripts/cleanup.sh b/scripts/cleanup.sh deleted file mode 100755 index 827c14b4a2dcc..0000000000000 --- a/scripts/cleanup.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash - -org="$1" -repo="$2" - -echo "Deleting workflow runs for $org/$repo" - -workflows_temp=$(mktemp) # Creates a temporary file to store workflow data. - -gh api repos/$org/$repo/actions/workflows | jq -r '.workflows[] | [.id, .path] | @tsv' > $workflows_temp # Lookup workflow -cat "$workflows_temp" - -workflows_names=$(awk '{print $2}' $workflows_temp | grep -v "main") - -if [ -z "$workflows_names" ]; then - - echo "All workflows are either successful or failed. Nothing to remove" - -else - - echo "Removing all the workflows that are not successful or failed" - - for workflow_name in $workflows_names; do - - workflow_filename=$(basename "$workflow_name") - echo "Deleting |$workflow_filename|, please wait..." - - gh run list --limit 500 --workflow $workflow_filename --json databaseId | - jq -r '.[] | .databaseId' | - xargs -I{} gh run delete {} # Delete all workflow runs for workflow name - done -fi - -rm -rf $workflows_temp - -echo "Done." \ No newline at end of file