diff --git a/.forgejo/workflows/cleanup.yml b/.forgejo/workflows/cleanup.yml index 1bf204f..a8de85f 100644 --- a/.forgejo/workflows/cleanup.yml +++ b/.forgejo/workflows/cleanup.yml @@ -31,17 +31,18 @@ jobs: "$API/repos/$REPO/actions/runs?page=$PAGE&limit=50" \ -o runs.json - COUNT="$(jq '.workflow_runs | length' runs.json)" + COUNT="$(jq 'if type == "array" then length else (.workflow_runs // []) | length end' runs.json)" test "$COUNT" -gt 0 || break jq -r \ --arg cutoff "$CUTOFF" \ --arg current "$CURRENT_RUN_ID" \ - '.workflow_runs[] + 'if type == "array" then . else (.workflow_runs // []) end + | .[] + | select(type == "object") | select((.id | tostring) != $current) - | .status as $status - | select(["success", "failure", "cancelled", "skipped", "succeeded", "failed"] | index($status)) - | select(.created < $cutoff) + | select((.status // .conclusion) as $status | ["success", "failure", "cancelled", "skipped", "succeeded", "failed"] | index($status)) + | select((.created // .created_at) < $cutoff) | .id' runs.json \ >> "$DELETE_IDS"