Skip to content

Commit 148a9ea

Browse files
chore: fix oneper build workflow (#7189)
* test: fix PR number extraction in workflow - Replace fragile regex parsing with GitHub API call - Remove hardcoded fallback to 6723 - Use curl + jq instead of gh CLI for better compatibility * clean: remove test branch trigger * Update main-build.yaml * Update main-build.yaml
1 parent 3fedea6 commit 148a9ea

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

.github/workflows/main-build.yaml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)