# Check CI and Review Status

## Check CI Status (GitHub)

```bash
if [ "$GIT_PROVIDER" = "github" ]; then
  CI_STATUS=$(gh pr checks $PR_NUMBER --json state --jq '.[].state' | sort -u)

  [[ "$CI_STATUS" == *"FAILURE"* ]] && {
    echo "❌ CI checks failing"
    gh pr checks $PR_NUMBER

    if [ "$auto_mode" != true ]; then
      AskUserQuestion:
        header: "CI"
        question: "CI checks are failing. Continue anyway?"
        options:
          - label: "Wait for fix"
          - label: "Merge anyway (not recommended)"
    fi
  }
fi
```

## Check Review Status (GitHub)

```bash
if [ "$GIT_PROVIDER" = "github" ]; then
  REVIEWS=$(gh pr view $PR_NUMBER --json reviews --jq '.reviews | map(select(.state == "APPROVED")) | length')
  REQUIRED_REVIEWS=$(gh api repos/:owner/:repo --jq '.default_branch_protection.required_pull_request_reviews.required_approving_review_count // 0')

  [ "$REVIEWS" -lt "$REQUIRED_REVIEWS" ] && {
    echo "⚠️ Needs $REQUIRED_REVIEWS approvals, has $REVIEWS"
  }
fi
```
