Skip to content

Commit 5e42782

Browse files
authored
fix: branch for pr number (#16)
Signed-off-by: Rishav Dhar <19497993+rdhar@users.noreply.github.com>
1 parent 0e23a69 commit 5e42782

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ runs:
1818
shell: bash
1919
run: |
2020
# Fallback on empty string if the branch is not found.
21-
branch=${{ github.ref_name || github.head_ref || github.ref || '' }}
21+
branch=${{ github.ref_name || github.head_ref || github.ref || '0' }}
2222
2323
# Get PR number using GitHub API for different event triggers.
2424
if [[ "$GITHUB_EVENT_NAME" == "push" ]]; then
@@ -30,7 +30,7 @@ runs:
3030
number=$(echo "${GITHUB_REF_NAME}" | sed -n 's/.*pr-\([0-9]*\)-.*/\1/p')
3131
else
3232
# Get the PR number from branch name, otherwise fallback on 0 if the PR number is not found.
33-
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 }}
33+
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="${branch}" | jq '.[0].number // 0')
3434
fi
3535
3636
echo "branch=$branch" >> "$GITHUB_OUTPUT"

0 commit comments

Comments
 (0)