1
0
Fork 1
mirror of https://github.com/zen-browser/desktop.git synced 2025-07-08 14:09:58 +02:00

Update remove-failed-jobs.sh

Signed-off-by: Cristian Cezar Moisés <ethicalhacker@riseup.net>
This commit is contained in:
Cristian Cezar Moisés 2025-01-03 23:07:12 +00:00 committed by GitHub
parent cd03077b77
commit c38c82bf6a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,5 +1,7 @@
#!/bin/bash
gh_bulk_delete_workflow_runs() { gh_bulk_delete_workflow_runs() {
repo=$1 local repo=$1
# Ensure the repo argument is provided # Ensure the repo argument is provided
if [[ -z "$repo" ]]; then if [[ -z "$repo" ]]; then
@ -7,6 +9,8 @@ gh_bulk_delete_workflow_runs() {
return 1 return 1
fi fi
# Fetch workflow runs that are cancelled, failed, or timed out
local runs
runs=$(gh api repos/$repo/actions/runs --paginate | runs=$(gh api repos/$repo/actions/runs --paginate |
jq -r '.workflow_runs[] | jq -r '.workflow_runs[] |
select(.conclusion == "cancelled" or select(.conclusion == "cancelled" or
@ -14,12 +18,28 @@ gh_bulk_delete_workflow_runs() {
.conclusion == "timed_out") | .conclusion == "timed_out") |
.id') .id')
if [[ -z "$runs" ]]; then
echo "No workflow runs found for $repo with the specified conclusions."
return 0
fi
# Loop through each run and delete it
while IFS= read -r run; do while IFS= read -r run; do
echo "Deleting run https://github.com/$repo/actions/runs/$run" echo "Attempting to delete run: https://github.com/$repo/actions/runs/$run"
gh api -X DELETE repos/$repo/actions/runs/$run --silent
# Perform the deletion
if gh api -X DELETE repos/$repo/actions/runs/$run --silent; then
echo "Successfully deleted run: $run"
else
echo "Error deleting run: $run" >&2
fi
# Optional delay to avoid hitting API rate limits
sleep 1
done <<< "$runs" done <<< "$runs"
echo "All workflow runs for $repo have been deleted." echo "Completed deletion process for workflow runs in $repo."
} }
# Execute the function with the provided argument
gh_bulk_delete_workflow_runs "$1" gh_bulk_delete_workflow_runs "$1"