Skip to content

Commit 9394964

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 9394964

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
name: CodeRabbit
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+
const commentExists = comments.some(c => (c.body ?? '').includes(triggerComment));
30+
31+
if (!commentExists) {
32+
await github.rest.issues.createComment({
33+
owner,
34+
repo,
35+
issue_number,
36+
body: triggerComment
37+
});
38+
console.log('CodeRabbit review comment posted.');
39+
} else {
40+
console.log('CodeRabbit review comment already exists, skipping.');
41+
}

0 commit comments

Comments
 (0)