diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index 83c1c2a29..1561a8d6a 100644 --- a/.github/workflows/backport.yml +++ b/.github/workflows/backport.yml @@ -20,6 +20,7 @@ jobs: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} PR_TITLE: ${{ github.event.pull_request.title }} + PR_NUMBER: ${{ github.event.pull_request.number }} REPO: ${{ github.repository }} run: | # Backport PR titles follow the pattern: [9.2] Original title (#1234) @@ -29,6 +30,7 @@ jobs: exit 0 fi echo "Original PR: #$ORIGINAL_PR" + echo "Just-merged backport PR: #$PR_NUMBER" HAS_LABEL=$(gh pr view "$ORIGINAL_PR" --repo "$REPO" --json labels \ --jq '[.labels[].name] | if index("backport-pending") then "true" else "false" end') @@ -37,9 +39,10 @@ jobs: exit 0 fi + # Count open backport PRs, excluding the just-merged PR (API eventual consistency). OPEN_BACKPORTS=$(gh pr list --repo "$REPO" --label backport --state open \ --json number,title \ - --jq "[.[] | select(.title | test(\"\\\\(#${ORIGINAL_PR}\\\\)\"))] | length") + --jq "[.[] | select(.number != ${PR_NUMBER}) | select(.title | test(\"\\\\(#${ORIGINAL_PR}\\\\)\"))] | length") echo "Open backport PRs remaining: $OPEN_BACKPORTS" if [ "$OPEN_BACKPORTS" -eq 0 ]; then