diff --git a/.github/workflows/ci-cleanup-workflows.yaml b/.github/workflows/ci-cleanup-workflows.yaml new file mode 100644 index 000000000..9de04769a --- /dev/null +++ b/.github/workflows/ci-cleanup-workflows.yaml @@ -0,0 +1,21 @@ +on: + schedule: + - "11 0 * * *" + +permissions: + actions: write + +jobs: + cleanup: + runs-on: ubuntu-latest + steps: + - id: cleanup + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + AFTER: "14d" + LIMIT: 500 + run: | + DATE="$(date -uI -v -$AFTER)" + echo "Removing workflow runs older than $AFTER..." + gh run list --json databaseId -q '.[].databaseId' --created "<=$DATE" --limit "$LIMIT" | \ + xargs -IID gh run delete ID \ No newline at end of file