@@ -23,18 +23,6 @@ async function when_suspicious({ github, context, failed_checks }){
23
23
24
24
// REFACTO: might wanna use a score of confidence (how suspicious it is), then react on that
25
25
26
- const { owner, repo } = context . repo ;
27
- const issueNumber = context . payload . number ; // either issue or PR
28
-
29
- if ( ! configuration . label_if_suspicious ) {
30
- await github . rest . issues . addLabels ( {
31
- owner,
32
- repo,
33
- issue_number : issueNumber ,
34
- labels : [ "suspicious" ]
35
- } ) ;
36
- }
37
-
38
26
const reasons = failed_checks . map ( check => `- ${ check . reason } ` ) . join ( "\n> " ) ;
39
27
const commentBody = `> [!WARNING] This issue/PR has been automatically flagged as [suspicious] as it might not meet contribution requirements.
40
28
> Please read our contribution guide before submitting.
@@ -46,6 +34,12 @@ ${reasons}
46
34
47
35
console . log ( "Body of the produced comment:\n" , commentBody ) ;
48
36
37
+ if ( context . eventName === 'workflow_dispatch' ) // so we can test manually
38
+ return ;
39
+
40
+ const { owner, repo } = context . repo ;
41
+ const issueNumber = context . payload . number ; // either issue or PR
42
+
49
43
if ( configuration . comment_if_suspicious ) {
50
44
await github . rest . issues . createComment ( {
51
45
owner,
@@ -54,6 +48,14 @@ ${reasons}
54
48
body : `${ commentBody } `
55
49
} ) ;
56
50
}
51
+ if ( ! configuration . label_if_suspicious ) {
52
+ await github . rest . issues . addLabels ( {
53
+ owner,
54
+ repo,
55
+ issue_number : issueNumber ,
56
+ labels : [ "suspicious" ]
57
+ } ) ;
58
+ }
57
59
if ( configuration . close_if_suspicious ) {
58
60
await github . rest . issues . update ( {
59
61
owner,
@@ -103,6 +105,10 @@ module.exports = async ({ github, context, core }) => {
103
105
return create_at >= time_point ;
104
106
} ) ( ) ;
105
107
108
+ // ⚠️ simulate a newly-created fake account
109
+ WasAuthorRecentlyCreated = true ;
110
+ // ⚠️
111
+
106
112
const isTitleOrBodyTooShort = ( ( ) => {
107
113
108
114
if ( context . eventName === 'workflow_dispatch' ) // issues or pull_request
0 commit comments