From dd3082b1ae53c02f963d6d033aafae3cf1fe5f4c Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Wed, 14 Oct 2026 13:28:22 +0200 Subject: [PATCH] =?UTF-8?q?ci:=20fix=20purge=20script=20=E2=80=94=20preser?= =?UTF-8?q?ve=20PR=20runs=20for=20open=20PRs=20(including=20forks)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The purge script was deleting workflow runs for PRs from forks because it only checked branch existence in the main repo (X11Libre/xserver). Fork PR branches don't exist there, so their runs were deleted immediately. Fix: fetch the 'pull_requests' field from the workflow run API and skip deletion if any associated PR is still open. Also fetch head_repository for logging. Signed-off-by: Enrico Weigelt, metux IT consult --- .../github/gh-purge-deleted-branch-workflows.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/scripts/github/gh-purge-deleted-branch-workflows.sh b/.github/scripts/github/gh-purge-deleted-branch-workflows.sh index f6c55981c8..f45d3bd49c 100755 --- a/.github/scripts/github/gh-purge-deleted-branch-workflows.sh +++ b/.github/scripts/github/gh-purge-deleted-branch-workflows.sh @@ -77,22 +77,31 @@ log_info "Found $(echo "$existing_branches" | wc -l) branches." log_info "Fetching workflow runs..." gh api -H "Accept: application/vnd.github+json" \ "/repos/${REPO}/actions/runs?per_page=100" --paginate \ - | jq -c '.workflow_runs[] | {id: .id, branch: .head_branch, workflow: .name}' \ + | jq -c '.workflow_runs[] | {id: .id, branch: .head_branch, workflow: .name, pull_requests: .pull_requests, head_repository: .head_repository}' \ | while read -r run; do run_id=$(echo "$run" | jq -r '.id') run_branch=$(echo "$run" | jq -r '.branch') workflow_name=$(echo "$run" | jq -r '.workflow') + pull_requests=$(echo "$run" | jq -c '.pull_requests') + head_repo=$(echo "$run" | jq -r '.head_repository.full_name // empty') if [[ -z "$run_branch" ]]; then log_warn "Run $run_id has no branch (skipping)." continue fi - # Skip if branch exists + # Skip if branch exists in main repo if echo "$existing_branches" | grep -qx "$run_branch"; then continue fi + # Skip if run is associated with an OPEN pull request + # (pull_requests array contains PR objects with .state field) + if echo "$pull_requests" | jq -e 'any(.state == "open")' >/dev/null 2>&1; then + log_info "Skipping run $run_id (branch: $run_branch) — associated with open PR" + continue + fi + # Skip if workflow filter is set and does not match if [[ -n "$WORKFLOW_FILTER" && "$workflow_name" != "$WORKFLOW_FILTER" ]]; then continue