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