Skip to content

Add CodeRabbit approval handler and sync PR labels for review status#64

Open
kpj2006 wants to merge 3 commits intoAOSSIE-Org:mainfrom
kpj2006:coderabbit_approve
Open

Add CodeRabbit approval handler and sync PR labels for review status#64
kpj2006 wants to merge 3 commits intoAOSSIE-Org:mainfrom
kpj2006:coderabbit_approve

Conversation

@kpj2006
Copy link
Contributor

@kpj2006 kpj2006 commented Feb 15, 2026

Addressed Issues:

Screenshots/Recordings:

Additional Notes:

Checklist

  • My code follows the project's code style and conventions
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings or errors
  • I have joined the Discord server and I will share a link to this PR with the project maintainers there
  • I have read the Contributing Guidelines

⚠️ AI Notice - Important!

We encourage contributors to use AI tools responsibly when creating Pull Requests. While AI can be a valuable aid, it is essential to ensure that your contributions meet the task requirements, build successfully, include relevant tests, and pass all linters. Submissions that do not meet these standards may be closed without warning to maintain the quality and integrity of the project. Please take the time to understand the changes you are proposing and their impact.

Summary by CodeRabbit

  • Chores
    • Added an automated workflow that detects automated review approvals and updates PR labels—removing any pending-review label when appropriate and adding an approved label.
    • Added a PR sync step that marks PRs with a pending-review label (skipped for certain edit events) to improve visibility of review status.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 15, 2026

Walkthrough

Adds a new GitHub Actions workflow that reacts to CodeRabbit approvals on PR reviews to swap labels, and augments the PR label sync workflow to assign a pending-coderabbit-review label to PRs.

Changes

Cohort / File(s) Summary
CodeRabbit Approval Handler
\.github/workflows/coderabbit-approval.yml
New workflow triggered on pull_request_review (submitted). Detects reviewer coderabbitai / coderabbitai[bot] with approved state, removes pending-coderabbit-review (handles missing/404), adds coderabbit-approved, and outputs a completion summary.
Label Sync Enhancement
\.github/workflows/sync-pr-labels.yml
Adds a step to apply pending-coderabbit-review via actions/github-script (runs when event action != edited), inserted before existing summary step.

Sequence Diagram(s)

sequenceDiagram
  participant PR as Pull Request
  participant GH as GitHub Actions
  participant API as GitHub API
  participant Bot as CodeRabbit (coderabbitai)

  PR->>GH: pull_request_review (submitted)
  GH->>Bot: inspect review author & state
  GH->>GH: evaluate if reviewer == coderabbitai and state == approved
  alt approved by CodeRabbit
    GH->>API: DELETE label `pending-coderabbit-review` (ignore 404)
    API-->>GH: 200 / 404 handled
    GH->>API: POST label `coderabbit-approved`
    API-->>GH: label added
    GH-->>PR: emit summary/log
  else not CodeRabbit-approved
    GH-->>PR: no label changes
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • add sync-pr-labels #6: Modifies the same \.github/workflows/sync-pr-labels.yml to introduce labeling steps related to pending-coderabbit-review.

Suggested reviewers

  • Zahnentferner

Poem

🐰 I hopped through workflows, labels in tow,
From pending to approved, I peeked and I know,
A bot gave a nod, scripts ran with cheer,
Labels swapped neatly — carrot-coated gear! 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the two main changes: adding a CodeRabbit approval handler workflow and syncing PR labels for review status tracking.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. 🎉


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added size/M and removed size/M labels Feb 15, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Fix all issues with AI agents
In @.github/workflows/coderabbit-approval.yml:
- Around line 105-119: Update the "Summary" step script to avoid unconditionally
claiming labels were removed/added; instead read the prior step outputs (e.g.,
check steps.remove-pending-label.outputs.removed and
steps.add-coderabbit-label.outputs.added or whatever output names your
label-removal/label-add steps set) and conditionally log "Removed
'pending-coderabbit-review' label" only if removed==='true' and "Added
'coderabbit-approved' label" only if added==='true', otherwise log a best-effort
or attempted message; modify the console.log calls inside the Summary step
script accordingly so the messages reflect actual outcomes from those steps.
- Around line 3-5: Update the pull_request_review trigger to include the
"dismissed" type in addition to "submitted" and add a conditional job/step that
runs when github.event.action == 'dismissed' to remove the "coderabbit-approved"
label (and optionally add "pending-coderabbit-review"); specifically modify the
pull_request_review.types array and add a step that uses the existing label
handling logic (targeting the "coderabbit-approved" and
"pending-coderabbit-review" labels) to remove the approved label on dismissal
and restore the pending label if desired.
- Around line 86-103: The "Add CodeRabbit approved label" step currently calls
github.rest.issues.addLabels without error handling; wrap the await
github.rest.issues.addLabels(...) call in a try/catch, catch the error and log a
clear message including prNumber and the label name (e.g. 'coderabbit-approved')
and the error details, then surface the failure (either by rethrowing a new
Error with that message or calling core.setFailed) so the workflow fails with a
meaningful message instead of an opaque stack trace.

In @.github/workflows/sync-pr-labels.yml:
- Around line 318-333: The "Add pending CodeRabbit review label" step
unconditionally re-adds 'pending-coderabbit-review' on PR "edited" events and
lacks error handling; change the job step to run only when code-changing events
occur by adding a condition (if: github.event.action != 'edited') and wrap the
call to github.rest.issues.addLabels in a try/catch similar to the approval
workflow so failures (e.g., label missing) are caught and logged instead of
failing the run; locate the step by its name "Add pending CodeRabbit review
label" and update the script around prNumber and github.rest.issues.addLabels to
include the conditional gating and error handling/logging.

@github-actions github-actions bot added size/M and removed size/M labels Feb 15, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In @.github/workflows/coderabbit-approval.yml:
- Around line 12-13: The job key remove-pending-label is misleading; rename it
to a descriptive name like handle-coderabbit-review and update all references to
that job key (e.g., any "needs:" entries, workflow callers, or job status
checks) so CI still wires correctly; open the workflow YAML, change the job
identifier remove-pending-label to handle-coderabbit-review, and adjust any
usages/comments within the same file to match the new identifier to avoid
breaking dependencies.
- Around line 22-42: Extend the approval-check logic to detect the dismissed
case: add a boolean is_coderabbit_dismissed (compute as isCodeRabbit && state
=== 'dismissed'), set it via core.setOutput('is_coderabbit_dismissed',
is_coderabbit_dismissed), and return it in the step result alongside
isCodeRabbit/isApproved/shouldRemoveLabel; then add a new workflow step named
"Handle dismissed CodeRabbit review" that runs when
steps.check-approval.outputs.is_coderabbit_dismissed == 'true' and uses
actions/github-script to call github.rest.issues.removeLabel to remove
'coderabbit-approved' (ignore 404) and github.rest.issues.addLabels to add
'pending-coderabbit-review' (log errors), using
context.payload.pull_request.number (prNumber) and context.repo for owner/repo.

@github-actions github-actions bot added size/M and removed size/M labels Feb 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant