Skip to content

Comments

Modifications to the web hook bot#244

Merged
tpantelis merged 2 commits intosubmariner-io:develfrom
tpantelis:web_hook_updates
Feb 13, 2026
Merged

Modifications to the web hook bot#244
tpantelis merged 2 commits intosubmariner-io:develfrom
tpantelis:web_hook_updates

Conversation

@tpantelis
Copy link
Contributor

@tpantelis tpantelis commented Feb 12, 2026

See commits for details.

Summary by CodeRabbit

  • New Features

    • Bot pull requests from dependabot and submariner-bot are automatically approved and have auto-merge enabled when opened.
  • Chores

    • Simplified CI workflow triggers by removing the Konflux actor, leaving only dependabot and submariner-bot.

@submariner-bot
Copy link

🤖 Created branch: z_pr244/tpantelis/web_hook_updates

@coderabbitai
Copy link

coderabbitai bot commented Feb 12, 2026

Walkthrough

Adds GH client methods to approve PRs and enable GraphQL auto-merge, initializes an HTTP client, and updates the pull request handler to detect bot-authored PRs and call approve + enable-auto-merge. Removes Konflux actor and auto-merge steps from the workflow trigger.

Changes

Cohort / File(s) Summary
Workflow trigger
.github/workflows/coderabbit-trigger.yml
Removed Konflux actor from workflow triggers and removed workflow auto-merge steps; workflow now only posts the CodeRabbit review comment.
GH client interface & implementation
pkg/ghclient/gh.go
Added ApprovePR(prNum int) error and EnableAutoMerge(prNum int) error to GH interface; implemented review creation via REST and auto-merge enablement via GraphQL; added httpClient *http.Client to ghClient and related HTTP/JSON handling.
Pull request handler
pkg/handler/pullrequest/handler.go
Added isSubmarinerBotPR and aggregated bot check (isBotPR); in openOrSync, detect bot-authored PRs and call ApprovePR and EnableAutoMerge, with error logging.

Sequence Diagram(s)

sequenceDiagram
    actor GitHub
    participant Handler as Pull Request Handler
    participant GHClient as GH Client
    participant GitHubAPI as GitHub API

    GitHub->>Handler: PR opened (bot-authored)
    activate Handler
    Handler->>Handler: classify PR (isBotPR / isSubmarinerBotPR)
    alt Bot PR detected
        Handler->>GHClient: ApprovePR(prNum)
        activate GHClient
        GHClient->>GitHubAPI: REST POST CreateReview (APPROVE)
        GitHubAPI-->>GHClient: review response
        deactivate GHClient
        Handler->>GHClient: EnableAutoMerge(prNum)
        activate GHClient
        GHClient->>GitHubAPI: REST GET PR (node_id)
        GitHubAPI-->>GHClient: PR node_id
        GHClient->>GitHubAPI: GraphQL POST enablePullRequestAutoMerge (REBASE)
        GitHubAPI-->>GHClient: mutation response
        deactivate GHClient
    end
    deactivate Handler
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • Oats87
  • sridhargaddam
  • skitt
  • dfarrell07
🚥 Pre-merge checks | ✅ 3 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Modifications to the web hook bot' is vague and generic, using non-descriptive language that doesn't convey the specific changes. Consider a more specific title that captures the main change, such as 'Add auto-merge and approval for bot PRs' or 'Refactor workflow trigger and add PR automation'.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into devel
Actionable Comments Resolved ✅ Passed No new actionable comments introduced by this PR; pre-existing TODO comments were not added in this change.

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


No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
pkg/ghclient/gh.go (2)

136-136: Use http.NewRequestWithContext instead of http.NewRequest.

http.NewRequest creates a request with no context, which means it can't be cancelled or timed out. This is a minor concern but aligns with Go best practices (and many linters flag this).

♻️ Proposed fix
-	req, err := http.NewRequest("POST", "https://api.github.com/graphql", bytes.NewBuffer(jsonBody))
+	req, err := http.NewRequestWithContext(context.Background(), "POST", "https://api.github.com/graphql", bytes.NewBuffer(jsonBody))

96-169: GraphQL error response handling could miss partial failures.

The current code checks for an "errors" key in the response, which is good. However, the GraphQL spec allows responses with both "data" and "errors" (partial success). More importantly, if the "data" field contains null for the mutation result alongside no top-level "errors", the operation may have silently failed. The current handling is likely sufficient for this use case, but worth noting.

Also, the GitHub GraphQL API URL is hardcoded to https://api.github.com/graphql. If this bot ever needs to work with GitHub Enterprise, consider deriving the URL from the go-github client's base URL.


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.

This commit modifies the webhook bot to automatically approve and
enable auto-merge all PRs created by Depandabot, Konflux and
submariner-bot.

Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
Since the webhook bot now handles auto-merge for all bot PRs
(Dependabot, Konflux, and submariner-bot), this commit removes
the duplicate auto-merge functionality from the CodeRabbit trigger
workflow.

Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
@tpantelis tpantelis merged commit 417b75d into submariner-io:devel Feb 13, 2026
8 checks passed
@submariner-bot
Copy link

🤖 Closed branches: [z_pr244/tpantelis/web_hook_updates]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants