fix: remove --json flag for gh CLI compatibility
fix: remove --json flag for gh CLI compatibility
This commit is contained in:
@@ -155,28 +155,27 @@ jobs:
|
||||
> **Note:** This PR was created with force mode enabled."
|
||||
fi
|
||||
|
||||
# Create PR with JSON output for reliable success detection
|
||||
PR_RESULT=$(gh pr create \
|
||||
# Create PR (compatible with older gh CLI versions)
|
||||
set +e
|
||||
PR_URL=$(gh pr create \
|
||||
--title "chore: update WhatsApp Web version" \
|
||||
--body "$PR_BODY" \
|
||||
--base master \
|
||||
--head "$BRANCH_NAME" \
|
||||
--json url,number 2>&1) || PR_CREATE_FAILED=true
|
||||
--head "$BRANCH_NAME" 2>&1)
|
||||
PR_CREATE_EXIT=$?
|
||||
set -e
|
||||
|
||||
# Check if PR was created successfully by parsing JSON
|
||||
if [ -z "$PR_CREATE_FAILED" ] && echo "$PR_RESULT" | jq -e '.url' > /dev/null 2>&1; then
|
||||
PR_URL=$(echo "$PR_RESULT" | jq -r '.url')
|
||||
PR_NUMBER=$(echo "$PR_RESULT" | jq -r '.number')
|
||||
echo "PR created successfully: $PR_URL (PR #$PR_NUMBER)"
|
||||
if [ $PR_CREATE_EXIT -eq 0 ]; then
|
||||
echo "✅ PR created successfully: $PR_URL"
|
||||
|
||||
# Auto-merge the PR (squash merge)
|
||||
# Note: This requires branch protection rules to be satisfied
|
||||
# If checks haven't completed yet, auto-merge will queue the merge
|
||||
echo "Attempting to enable auto-merge..."
|
||||
if gh pr merge "$BRANCH_NAME" --squash --auto --delete-branch; then
|
||||
if gh pr merge "$BRANCH_NAME" --squash --auto --delete-branch 2>/dev/null; then
|
||||
echo "✅ Auto-merge enabled - PR will merge automatically when checks pass"
|
||||
else
|
||||
echo "⚠️ Auto-merge not available - PR #$PR_NUMBER created for manual review"
|
||||
echo "⚠️ Auto-merge not available - PR created for manual review"
|
||||
echo "This may happen if:"
|
||||
echo " - Required status checks haven't completed yet"
|
||||
echo " - Branch protection rules require manual approval"
|
||||
@@ -185,13 +184,16 @@ jobs:
|
||||
else
|
||||
# PR creation failed - could be duplicate or other error
|
||||
echo "⚠️ Could not create PR. Checking if PR already exists..."
|
||||
EXISTING_PR=$(gh pr list --head "$BRANCH_NAME" --json number,url --jq '.[0]')
|
||||
|
||||
# Check for existing PR (without --json for compatibility)
|
||||
EXISTING_PR=$(gh pr list --head "$BRANCH_NAME" --state open 2>/dev/null | head -1)
|
||||
|
||||
if [ -n "$EXISTING_PR" ]; then
|
||||
EXISTING_URL=$(echo "$EXISTING_PR" | jq -r '.url')
|
||||
EXISTING_NUMBER=$(echo "$EXISTING_PR" | jq -r '.number')
|
||||
echo "PR already exists: $EXISTING_URL (PR #$EXISTING_NUMBER)"
|
||||
echo "ℹ️ PR already exists for branch $BRANCH_NAME"
|
||||
echo "$EXISTING_PR"
|
||||
else
|
||||
echo "❌ PR creation failed: $PR_RESULT"
|
||||
echo "❌ PR creation failed with error:"
|
||||
echo "$PR_URL"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user