Skip to content

Commit

Permalink
fix: get pr number from branch (#417)
Browse files Browse the repository at this point in the history
* fix: get pr number from branch

Signed-off-by: Rishav Dhar <[email protected]>

* retry on push event

Signed-off-by: Rishav Dhar <[email protected]>

* trigger

Signed-off-by: Rishav Dhar <[email protected]>

* trigger on push

Signed-off-by: Rishav Dhar <[email protected]>

* scope

Signed-off-by: Rishav Dhar <[email protected]>

* reset tests

Signed-off-by: Rishav Dhar <[email protected]>

* remove debug

Signed-off-by: Rishav Dhar <[email protected]>

---------

Signed-off-by: Rishav Dhar <[email protected]>
  • Loading branch information
rdhar authored Feb 10, 2025
1 parent db1b947 commit cd74f1c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ runs:
pr_number=$(echo "${GITHUB_REF_NAME}" | sed -n 's/.*pr-\([0-9]*\)-.*/\1/p')
else
# Get the PR number from branch name, otherwise fallback on 0 if the PR number is not found.
pr_number=$(gh api /repos/{owner}/{repo}/pulls --header "$GH_API" --method GET --field per_page=100 --field head="${branch}" | jq .[0].number) || ${{ github.event.number || github.event.issue.number || 0 }}
pr_number=${{ github.event.number || github.event.issue.number }} || $(gh api /repos/{owner}/{repo}/pulls --header "$GH_API" --method GET --field per_page=100 --field head="${{ github.ref_name || github.head_ref || github.ref || '0' }}" | jq '.[0].number // 0')
fi
echo "pr=$pr_number" >> "$GITHUB_OUTPUT"
Expand Down

0 comments on commit cd74f1c

Please sign in to comment.