Skip to content

Commit 5783a1d

Browse files
committed
Add reusable workflow to trigger CodeRabbit review on bot PRs
CodeRabbit has implicit default behavior that automatically skips bot PRs. The recommended solution is to add a workflow that adds a PR comment to trigger review. This commit adds a reusable workflow that centralizes the logic and can be called from a small workflow in each repository. Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
1 parent ddcbec0 commit 5783a1d

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
name: Trigger CodeRabbit (Reusable)
3+
on:
4+
workflow_call:
5+
inputs:
6+
pr_number:
7+
required: true
8+
type: number
9+
10+
jobs:
11+
trigger-coderabbit:
12+
runs-on: ubuntu-latest
13+
if: github.actor == 'dependabot[bot]' || github.actor == 'submariner-bot'
14+
permissions:
15+
issues: write
16+
steps:
17+
- uses: actions/github-script@v8
18+
with:
19+
script: |
20+
const owner = context.repo.owner;
21+
const repo = context.repo.repo;
22+
const issue_number = ${{ inputs.pr_number }};
23+
24+
const triggerComment = '@coderabbitai review';
25+
const comments = await github.paginate(
26+
github.rest.issues.listComments,
27+
{ owner, repo, issue_number, per_page: 100 }
28+
);
29+
30+
const commentExists = comments.some(c => (c.body ?? '').includes(triggerComment));
31+
32+
if (!commentExists) {
33+
await github.rest.issues.createComment({
34+
owner,
35+
repo,
36+
issue_number,
37+
body: triggerComment
38+
});
39+
console.log('CodeRabbit review comment posted.');
40+
} else {
41+
console.log('CodeRabbit review comment already exists, skipping.');
42+
}

0 commit comments

Comments
 (0)