diff --git a/.github/clear-gh-runs.sh b/.github/clear-gh-runs.sh new file mode 100644 index 00000000..11f3009d --- /dev/null +++ b/.github/clear-gh-runs.sh @@ -0,0 +1,18 @@ +# Idea from +# https://stackoverflow.com/a/65539398/6753144 +# + +OWNER=devlikeapro +REPO=whatsapp-http-api-plus + +# list workflows +gh api -X GET /repos/$OWNER/$REPO/actions/workflows | jq '.workflows[] | .name,.id' + +# copy the ID of the workflow you want to clear and set it +WORKFLOW_ID=40218610 + +# list runs +gh api -X GET /repos/$OWNER/$REPO/actions/workflows/$WORKFLOW_ID/runs --paginate | jq '.workflow_runs[] | .id' + +# delete runs +gh api -X GET /repos/$OWNER/$REPO/actions/workflows/$WORKFLOW_ID/runs --paginate | jq '.workflow_runs[] | .id' | xargs -I{} gh api -X DELETE /repos/$OWNER/$REPO/actions/runs/{} --silent