File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed
Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -24,17 +24,19 @@ jobs:
2424
2525 - name : Get merged PR number
2626 id : get-pr
27+ env :
28+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
2729 run : |
28- # Get the commit message of the merge commit
29- COMMIT_MSG =$(git log --format=%B -n 1 HEAD)
30- echo "Commit message : $COMMIT_MSG "
30+ # Get PR number for the current commit using GitHub API
31+ COMMIT_SHA =$(git rev-parse HEAD)
32+ echo "Getting PR for commit : $COMMIT_SHA "
3133
32- # Extract PR number from merge commit message (format: "Merge pull request #123 from...")
33- PR_NUMBER=$(echo "$COMMIT_MSG" | grep -o "Merge pull request #[0-9]*" | grep -o "[0-9]*" || echo "6723")
34+ PR_NUMBER=$(curl -s -H "Authorization: token $GH_TOKEN" \
35+ "https://api.github.com/repos/${{ github.repository }}/commits/$COMMIT_SHA/pulls" \
36+ | jq -r '.[0].number // empty')
3437
3538 if [ -z "$PR_NUMBER" ]; then
36- echo "❌ Could not extract PR number from commit message. This might not be a PR merge."
37- echo "Commit message was: $COMMIT_MSG"
39+ echo "❌ Could not find PR for commit $COMMIT_SHA"
3840 exit 1
3941 fi
4042
You can’t perform that action at this time.
0 commit comments