From f9cd06408cb5a3c3a2ba3760b9db8b7d1b5a15a1 Mon Sep 17 00:00:00 2001 From: yCodeTech Date: Fri, 21 Aug 2026 03:58:48 +0100 Subject: [PATCH] ci: sort PR list in numerical order in the update-changelog PR body. - Fixed the "Create or update changelog PR" step in the changelog CI to sort the PR list in numerical order in the existing update changelog PR body. This ensures that if a the CI run fails and a concurrent run succeeds, the PR number won't be in the wrong order when re-running the failed runs. The PR numbers will always be in numerical order. --- .github/workflows/changelog-ci.yml | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/.github/workflows/changelog-ci.yml b/.github/workflows/changelog-ci.yml index 8f2be74..d07812f 100644 --- a/.github/workflows/changelog-ci.yml +++ b/.github/workflows/changelog-ci.yml @@ -238,10 +238,28 @@ jobs: if [ "$CHANGELOG_PR_EXISTS" = "true" ]; then # Update existing PR + EXISTING_PR_NUMBER="${{ steps.check-existing-changelog-pr.outputs.changelog-pr-number }}" EXISTING_BODY="${{ steps.check-existing-changelog-pr.outputs.changelog-pr-body }}" - UPDATED_BODY="$EXISTING_BODY - - #$PR_NUMBER" + + # Extract the existing PR list + PR_LIST=$(printf '%s\n' "$EXISTING_BODY" | + sed -n '/^### Included PRs:/,$p' | + sed '1d') + + # Add the new PR and sort numerically + SORTED_PR_LIST=$( + { + printf '%s\n' "$PR_LIST" | + sed 's/^- #//' + printf '%s\n' "$PR_NUMBER" + } | + sort -n | + sed 's/^/- #/' + ) + + # Replace only the existing PR list + UPDATED_BODY="${EXISTING_BODY/"$PR_LIST"/"$SORTED_PR_LIST"}" gh pr edit "$EXISTING_PR_NUMBER" --body "$UPDATED_BODY" echo "✅ Updated changelog PR #$EXISTING_PR_NUMBER"