Skip to content

Commit 031011b

Browse files
zakisksavitaashture
authored andcommitted
Invalidate ok-to-test command on pushed commits
invalidated ok-to-test command on pushed commits as it is not needed there. Signed-off-by: Zaki Shaikh <[email protected]>
1 parent a6ddad4 commit 031011b

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

docs/content/docs/guide/gitops_commands.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ This means:
7070
3. `/retest <pipelinerun-name> branch:test`
7171
4. `/test <pipelinerun-name> branch:test`
7272

73+
Please note that the `/ok-to-test` command does not work on pushed commits, as it is specifically intended for pull requests to manage authorization. Since only authorized users are allowed to send `GitOps` commands on pushed commits,
74+
there is no need to use the `ok-to-test` command in this context.
75+
7376
To issue a `GitOps` comment on a pushed commit, you can follow these steps:
7477

7578
1. Go to your repository.

pkg/provider/github/detect.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,13 @@ func (v *Provider) detectTriggerTypeFromPayload(ghEventType string, eventInt any
102102
if provider.IsTestRetestComment(event.GetComment().GetBody()) {
103103
return triggertype.Retest, ""
104104
}
105-
if provider.IsOkToTestComment(event.GetComment().GetBody()) {
106-
return triggertype.OkToTest, ""
107-
}
108105
if provider.IsCancelComment(event.GetComment().GetBody()) {
109106
return triggertype.Cancel, ""
110107
}
108+
// Here, the `/ok-to-test` command is ignored because it is intended for pull requests.
109+
// For unauthorized users, it has no relevance to pushed commits, as only authorized users
110+
// are allowed to run CI on pushed commits. Therefore, the `ok-to-test` command holds no significance in this context.
111+
// However, it is left to be processed by the `on-comment` annotation rather than returning an error.
111112
}
112113
return triggertype.Comment, ""
113114
}

pkg/provider/github/detect_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,19 @@ func TestProvider_Detect(t *testing.T) {
295295
isGH: true,
296296
processReq: true,
297297
},
298+
{
299+
name: "commit comment Event with /ok-to-test being ignore as GitOps command on pushed commits",
300+
event: github.CommitCommentEvent{
301+
Action: github.Ptr("created"),
302+
Installation: &github.Installation{
303+
ID: &idd,
304+
},
305+
Comment: &github.RepositoryComment{Body: github.Ptr("/ok-to-test")},
306+
},
307+
eventType: "commit_comment",
308+
isGH: true,
309+
processReq: true,
310+
},
298311
}
299312

300313
for _, tt := range tests {

0 commit comments

Comments
 (0)