Add reusable workflow to trigger CodeRabbit review on bot PRs#231
Conversation
|
🤖 Created branch: z_pr231/tpantelis/add-coderabbit-dependabot-workflow |
|
Warning Rate limit exceeded@tpantelis has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 12 minutes and 31 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
WalkthroughA new GitHub Actions workflow file is introduced that automatically triggers CodeRabbit reviews on pull requests. The workflow is callable from other workflows, runs only for specific bot actors, and uses the GitHub API to check for and post review comments when absent. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes
Pre-merge checksCaution Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional.
❌ Failed checks (1 error)
✅ Passed checks (2 passed)
Comment |
28108e1 to
f2af61e
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
.github/workflows/coderabbit-trigger.yml (1)
13-21: Avoid duplicate trigger comments (optional).
As-is, every rerun posts another@coderabbitai reviewcomment. Consider checking existing comments first and only posting if absent.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/coderabbit-trigger.yml(1 hunks)
🔇 Additional comments (1)
.github/workflows/coderabbit-trigger.yml (1)
10-12: No change needed:pull-requests: writeis sufficient forissues.createCommenton pull requests.GitHub treats pull requests as issues, so
github.rest.issues.createCommentworks with eitherissues: writeorpull-requests: writepermissions. Since this workflow operates within a pull request context (context.issue.number), the currentpull-requests: writepermission is adequate and requires no modification.Likely an incorrect or invalid review comment.
f2af61e to
b0aeb41
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/coderabbit-trigger.yml(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Go
b0aeb41 to
5783a1d
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
.github/workflows/coderabbit-trigger.yml (1)
3-8: Tighten trigger-comment detection to reduce false positives (optional).
Right now any comment containing@coderabbitai review(even a human quoting it) will suppress posting. Consider matching exact body (trimmed) and/or restricting to comments authored bygithub-actions[bot]to keep the workflow deterministic.- const commentExists = comments.some(c => (c.body ?? '').includes(triggerComment)); + const commentExists = comments.some(c => + (c.user?.login === 'github-actions[bot]') && + ((c.body ?? '').trim() === triggerComment) + );Also applies to: 19-38
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/coderabbit-trigger.yml(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Go
🔇 Additional comments (1)
.github/workflows/coderabbit-trigger.yml (1)
17-28: No action needed.github.paginate()is fully supported and documented inactions/github-script@v8. The pre-authenticated Octokit client includes pagination capabilities, and this usage pattern is correct.Likely an incorrect or invalid review comment.
a017c07 to
ea65b30
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
.github/workflows/coderabbit-trigger.yml (1)
4-15: Consider improving testability and making the “already triggered” check stricter.
Right now the bot-only gate (Line 13) means a manual run (e.g., via a humanworkflow_dispatch) won’t do anything, which can be confusing when validating. Also,includes(triggerComment)(Line 29) can match quoted text; consider checkingtrim() === triggerCommentor using a unique marker comment body.Also applies to: 24-41
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
.github/workflows/coderabbit-trigger.yml(1 hunks).github/workflows/test-coderabbit-trigger.yml(1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.9)
.github/workflows/test-coderabbit-trigger.yml
13-13: reusable workflow call "./github/workflows/coderabbit-trigger.yml@add-coderabbit-dependabot-workflow" at "uses" is not following the format "owner/repo/path/to/workflow.yml@ref" nor "./path/to/workflow.yml". see https://docs.github.com/en/actions/learn-github-actions/reusing-workflows for more details
(workflow-call)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Go
3e82898 to
fcf2006
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
.github/workflows/test-cr-trigger.yml (1)
4-6: If this is a test-only workflow, gate it to avoid spamming bot comments on every PR.
Consider switching toworkflow_dispatch(or restricting withpaths,branches, or anif:on actor/label) so routine PRs don’t trigger it.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/test-cr-trigger.yml(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Go
fcf2006 to
9e0d4bf
Compare
9e0d4bf to
467d30d
Compare
|
@coderabbitai why do I get HttpError: Resource not accessible by integration when creating a pull request comment using actions/github-script? |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 1344 🏁 Script executed: Length of output: 166 @tpantelis The issue is that when calling a reusable workflow, permissions must be explicitly set in the calling workflow. The In your SolutionAdd a ---
name: Test CodeRabbit
on:
pull_request:
permissions:
contents: read
pull-requests: write
jobs:
test:
uses: ./.github/workflows/coderabbit-trigger.yml
with:
pr_number: 230
secrets: inheritAlternatively, if you want the calling workflow to have the most flexibility, you can use: permissions:
pull-requests: writeThis grants the necessary permission to create PR comments. The key point is that both the caller and the called workflow need appropriate permissions, or you can set them at the workflow level in the caller and they'll be inherited by the reusable workflow. |
1063fe3 to
8310a3b
Compare
|
@coderabbitai I tried adding pull_request write permission to the calling workflow but I still get "HttpError: Resource not accessible by integration". I also changed it to issues write permission in both the calling and called workflows but I still get "HttpError: Resource not accessible by integration". What is wrong? |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 2141 🌐 Web query: 💡 Result: Short summary — rules & restrictions for bot tokens on pull_request-triggered workflows:
Recommended actions:
If you want, tell me your exact use case (bot actions needed: comment, push, approve, create PR?) and I’ll recommend the safest workflow pattern and sample permissions. Citations:
@tpantelis The issue is a GitHub Actions security restriction: Solution: Use
|
8310a3b to
6ba4a52
Compare
|
@coderabbitai I added pull_request_target to the test calling workflow but it didn't trigger. Why? |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 935 @tpantelis The workflow didn't trigger because This is confirmed by checking the devel branch: SolutionYou have a chicken-and-egg situation. Here are your options: Option 1: Merge first, test later (Recommended)
Option 2: Test before mergingIf you want to test before merging:
Option 3: Use a different event for testingFor initial testing only, you could temporarily use on:
workflow_dispatch:
inputs:
pr_number:
description: 'PR number to comment on'
required: trueAlso noteYour pr_number: ${{ github.event.pull_request.number }}Given this is a new workflow being introduced, Option 1 is the most practical — merge it and verify it works on the next bot PR. 🧠 Learnings used |
6ba4a52 to
91634b7
Compare
|
@coderabbitai I changed the test workflow to use workflow_dispatch as you suggested but I don't see an option to run the workflow in the Actions tab |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 1884 @tpantelis The same issue applies here: This is confirmed by the output: Also, fix the pr_numberYou have with:
pr_number: 230To: with:
pr_number: ${{ inputs.pr_number }}Practical solutionsOption 1: Push directly to devel for testing (Quick test)# Push just the workflow files to devel temporarily
git checkout devel
git checkout coderabbit_231 -- .github/workflows/coderabbit-trigger.yml .github/workflows/test-cr-trigger.yml
git commit -m "temp: add workflows for testing"
git push origin develThen:
Option 2: Just merge and test naturally (Recommended)Since this workflow is specifically for bot PRs:
I recommend Option 2 unless you need immediate verification. The workflow is straightforward and will work once merged. 🧠 Learnings used |
91634b7 to
57a93eb
Compare
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
.github/workflows/coderabbit-trigger.yml (1)
17-18: Consider pinningactions/github-scriptto a commit SHA for supply-chain hardening.
Tags can move; pinning reduces risk.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/coderabbit-trigger.yml(1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: tpantelis
Repo: submariner-io/submariner-bot PR: 0
File: :0-0
Timestamp: 2025-12-12T18:37:30.877Z
Learning: GitHub Actions workflows triggered by bot PRs (Dependabot, submariner-bot) using the `pull_request` trigger always receive a read-only GITHUB_TOKEN, regardless of permissions set in the workflow. To enable write permissions for bot PRs, use `pull_request_target` instead, which runs in the base branch context with full permissions. This is safe when the workflow only performs API actions without checking out or executing PR code.
📚 Learning: 2025-12-12T18:37:30.877Z
Learnt from: tpantelis
Repo: submariner-io/submariner-bot PR: 0
File: :0-0
Timestamp: 2025-12-12T18:37:30.877Z
Learning: GitHub Actions workflows triggered by bot PRs (Dependabot, submariner-bot) using the `pull_request` trigger always receive a read-only GITHUB_TOKEN, regardless of permissions set in the workflow. To enable write permissions for bot PRs, use `pull_request_target` instead, which runs in the base branch context with full permissions. This is safe when the workflow only performs API actions without checking out or executing PR code.
Applied to files:
.github/workflows/coderabbit-trigger.yml
🔇 Additional comments (1)
.github/workflows/coderabbit-trigger.yml (1)
13-15: Verify the submariner bot actor string; consider allowing the[bot]variant.
Depending on how the bot authenticates,github.actormay besubmariner-bot[bot], so this job could silently never run.
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>
57a93eb to
887de52
Compare
|
@coderabbitai approve |
✅ Actions performedComments resolved and changes approved. |
|
🤖 Closed branches: [z_pr231/tpantelis/add-coderabbit-dependabot-workflow] |
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.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.