Skip to content

Commit c3288c3

Browse files
tpantelisskitt
authored andcommitted
Modify webhook bot and CodeRabbit workflow to handle konflux PRs
...same they do for dependabot PRs. Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
1 parent d6b1b8e commit c3288c3

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

.github/workflows/coderabbit-trigger.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
jobs:
1111
trigger-coderabbit:
1212
runs-on: ubuntu-latest
13-
if: github.actor == 'dependabot[bot]' || github.actor == 'submariner-bot'
13+
if: github.actor == 'dependabot[bot]' || github.actor == 'submariner-bot' || github.actor == 'red-hat-konflux-kflux-prd-rh02[bot]'
1414
permissions:
1515
contents: write
1616
pull-requests: write

pkg/handler/pullrequest/handler.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ func isDependabotPR(pr *github.PullRequestPayload) bool {
6868
return login == "dependabot[bot]" || login == "dependabot-preview[bot]" || login == "dependabot"
6969
}
7070

71+
func isKonfluxBotPR(pr *github.PullRequestPayload) bool {
72+
// Check if the PR author is Red Hat Konflux bot
73+
login := pr.PullRequest.User.Login
74+
return login == "red-hat-konflux-kflux-prd-rh02[bot]" || login == "red-hat-konflux-kflux-prd-rh02"
75+
}
76+
7177
func openOrSync(gitRepo *git.Git, pr *github.PullRequestPayload, gh ghclient.GH) error {
7278
prNum := int(pr.Number)
7379

@@ -78,13 +84,13 @@ func openOrSync(gitRepo *git.Git, pr *github.PullRequestPayload, gh ghclient.GH)
7884

7985
readyToReviewMsg := ""
8086
if config != nil && config.LabelApproved != nil {
81-
// Add ready-to-test label for Dependabot PRs when opened
82-
if pr.Action == "opened" && isDependabotPR(pr) {
87+
// Add ready-to-test label for Dependabot and Konflux bot PRs when opened
88+
if pr.Action == "opened" && (isDependabotPR(pr) || isKonfluxBotPR(pr)) {
8389
label := *config.LabelApproved.Label
84-
klog.Infof("Adding label %s to Dependabot PR #%d", label, prNum)
90+
klog.Infof("Adding label %s to PR #%d from %s", label, prNum, pr.PullRequest.User.Login)
8591
err = gh.AddLabel(prNum, label)
8692
if err != nil {
87-
klog.Errorf("Error while adding label %s to Dependabot PR #%d: %s", label, prNum, err)
93+
klog.Errorf("Error while adding label %s to PR #%d from %s: %s", label, prNum, pr.PullRequest.User.Login, err)
8894
}
8995
} else {
9096
readyToReviewMsg += fmt.Sprintf("\n🚀 Full E2E won't run until the %q label is applied. "+

0 commit comments

Comments
 (0)