# GitHub PR Review Workflow

## Environment

- `gh` CLI installed but cannot connect (macOS Go network stack issue), use `curl` with GitHub API instead
- GITHUB_TOKEN configured in `~/.zshrc`
- Token scopes: `repo`, `read:org`

## Common Commands

### View PR info
```bash
curl -s "https://api.github.com/repos/apache/celeborn/pulls/{PR_NUMBER}" \
  -H "Authorization: token $GITHUB_TOKEN" | python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('title',''), d.get('state',''), d.get('head',{}).get('ref',''))"
```

### Get PR diff
```bash
curl -s "https://api.github.com/repos/apache/celeborn/pulls/{PR_NUMBER}/files" \
  -H "Authorization: token $GITHUB_TOKEN" | python3 -c "import sys,json; [print(f['filename'], f.get('patch','')[:200]) for f in json.load(sys.stdin)]"
```

### Add inline review comment
```bash
curl -s -X POST "https://api.github.com/repos/apache/celeborn/pulls/{PR_NUMBER}/comments" \
  -H "Authorization: token $GITHUB_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Accept: application/vnd.github+json" \
  -d '{
    "body": "comment text",
    "path": "file path",
    "line": line_number,
    "side": "RIGHT",
    "commit_id": "PR head SHA"
  }'
```

### Submit review
```bash
curl -s -X POST "https://api.github.com/repos/apache/celeborn/pulls/{PR_NUMBER}/reviews" \
  -H "Authorization: token $GITHUB_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "body": "overall comment",
    "event": "COMMENT"
  }'
```

## Notes

- `line` is the new file line number (right side), use `side: "RIGHT"` for additions
- `commit_id` is the PR head commit SHA, obtainable from PR info
- `event` options: `COMMENT`, `APPROVE`, `REQUEST_CHANGES`
- Token is in `~/.zshrc`, do not commit to git
