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
This commit is contained in:
parent
3fedea67aa
commit
148a9eaa4a
1 changed files with 9 additions and 7 deletions
16
.github/workflows/main-build.yaml
vendored
16
.github/workflows/main-build.yaml
vendored
|
|
@ -24,17 +24,19 @@ jobs:
|
|||
|
||||
- name: Get merged PR number
|
||||
id: get-pr
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
# Get the commit message of the merge commit
|
||||
COMMIT_MSG=$(git log --format=%B -n 1 HEAD)
|
||||
echo "Commit message: $COMMIT_MSG"
|
||||
# Get PR number for the current commit using GitHub API
|
||||
COMMIT_SHA=$(git rev-parse HEAD)
|
||||
echo "Getting PR for commit: $COMMIT_SHA"
|
||||
|
||||
# Extract PR number from merge commit message (format: "Merge pull request #123 from...")
|
||||
PR_NUMBER=$(echo "$COMMIT_MSG" | grep -o "Merge pull request #[0-9]*" | grep -o "[0-9]*" || echo "6723")
|
||||
PR_NUMBER=$(curl -s -H "Authorization: token $GH_TOKEN" \
|
||||
"https://api.github.com/repos/${{ github.repository }}/commits/$COMMIT_SHA/pulls" \
|
||||
| jq -r '.[0].number // empty')
|
||||
|
||||
if [ -z "$PR_NUMBER" ]; then
|
||||
echo "❌ Could not extract PR number from commit message. This might not be a PR merge."
|
||||
echo "Commit message was: $COMMIT_MSG"
|
||||
echo "❌ Could not find PR for commit $COMMIT_SHA"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue