This is an automated email from the ASF dual-hosted git repository.

lprimak pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/shiro.git


The following commit(s) were added to refs/heads/main by this push:
     new 0c5e4a657 enh: fix labeler workflow (#2916)
0c5e4a657 is described below

commit 0c5e4a657d657e2d36a4e6f1eba74bdeda56dcd9
Author: Lenny Primak <[email protected]>
AuthorDate: Sat Oct 17 23:18:51 2026 -0400

    enh: fix labeler workflow (#2916)
---
 .github/workflows/labeler.yml | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml
index 461f31b2d..3e5924673 100644
--- a/.github/workflows/labeler.yml
+++ b/.github/workflows/labeler.yml
@@ -36,6 +36,8 @@ jobs:
           GH_TOKEN: ${{ github.token }}
           REPO: ${{ github.repository }}
           HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
+          HEAD_OWNER: ${{ 
github.event.workflow_run.head_repository.owner.login }}
+          HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }}
         run: |
           set -euo pipefail
           if ! [[ "$HEAD_SHA" =~ ^[0-9a-f]{40}$ ]]; then
@@ -43,8 +45,14 @@ jobs:
             exit 1
           fi
 
-          pr_numbers=$(gh api "repos/$REPO/commits/$HEAD_SHA/pulls" \
-            --jq '.[] | select(.state == "open") | .number')
+          # commits/{sha}/pulls does not find pull requests from forks,
+          # so look up by head owner:branch and match the head SHA
+          pr_numbers=$(gh api -X GET "repos/$REPO/pulls" \
+            -f state=open -f head="$HEAD_OWNER:$HEAD_BRANCH" \
+            --jq ".[] | select(.head.sha == \"$HEAD_SHA\") | .number")
+          if [[ -z "$pr_numbers" ]]; then
+            echo "::warning::No open pull request found for 
$HEAD_OWNER:$HEAD_BRANCH@$HEAD_SHA"
+          fi
           {
             echo "numbers<<EOF"
             printf '%s\n' "$pr_numbers"

Reply via email to