@@ -11,13 +11,6 @@ async function when_suspicious({ github, context, failed_checks }){
11
11
// issue_number: issueNumber,
12
12
// labels: ["suspicious"]
13
13
// });
14
- // await github.rest.issues.createComment({
15
- // owner,
16
- // repo,
17
- // issue_number: issueNumber,
18
- // body: "This issue/PR has been automatically closed as it does not meet our contribution guidelines. Please read our contribution guide before submitting."
19
- // });
20
-
21
14
22
15
const reasons = failed_checks . map ( check => `- ${ check . reason } ` ) . join ( "\n" ) ;
23
16
const commentBody = `This issue/PR has been automatically flagged as [suspicious] as it might not meet contribution requirements.
@@ -29,6 +22,12 @@ ${reasons}
29
22
` ;
30
23
31
24
console . log ( ">>> DEBUG:\n" , commentBody ) ;
25
+ // await github.rest.issues.createComment({
26
+ // owner,
27
+ // repo,
28
+ // issue_number: issueNumber,
29
+ // body: `${commentBody}`
30
+ // });
32
31
33
32
// TODO: if too many or critical checks failed, then consider immediatly closing:
34
33
@@ -56,21 +55,19 @@ class Check {
56
55
57
56
module . exports = async ( { github, context, core } ) => {
58
57
59
- const { owner, repo } = context . repo ;
60
- const { SHA } = process . env ;
61
- const author = context . actor ;
62
-
63
- const { data : user } = await github . rest . users . getByUsername ( { username : author } ) ;
58
+ // const {SHA} = process.env; // for octokit.rest.repos.getCommit
59
+ const username = context . actor ;
60
+ const { data : user } = await github . rest . users . getByUsername ( { username : username } ) ;
64
61
65
62
const isAuthorOnlyContributionOnGH = await ( async ( ) => {
66
63
// WARNING: Depending on the time of day, event latency can be anywhere from 30s to 6h. (source: https://octokit.github.io/rest.js/v21/)
67
64
const { data : events } = await github . rest . activity . listEventsForAuthenticatedUser ( {
68
- username : author ,
65
+ username : username ,
69
66
per_page : 1
70
67
} ) ;
71
68
72
- console . log ( ">>> is_author_only_contribution_on_GH : " , {
73
- username : author ,
69
+ console . log ( ">>> is_username_only_contribution_on_GH : " , {
70
+ username : username ,
74
71
events : events ,
75
72
events_length : events . length ,
76
73
result : events . length === 0 ,
@@ -86,23 +83,9 @@ module.exports = async ({ github, context, core }) => {
86
83
return value ;
87
84
} ) ( ) ;
88
85
const create_at = new Date ( user . created_at ) ;
89
-
90
- console . log ( ">>> was_author_account_recently_created: " , {
91
- time_point : time_point ,
92
- create_at : create_at ,
93
- result : create_at >= time_point
94
- } ) ;
95
-
96
86
return create_at >= time_point ;
97
87
} ) ( ) ;
98
88
99
- console . log ( ">>> " , {
100
- followers : user . followers ,
101
- following : user . following ,
102
- public_repos : user . public_repos ,
103
- public_gists : user . public_gists
104
- } )
105
-
106
89
const checks = [
107
90
new Check ( {
108
91
predicate : ( ) => user . followers !== 0 && user . following !== 0 ,
@@ -126,9 +109,8 @@ module.exports = async ({ github, context, core }) => {
126
109
const failed_checks = checks . filter ( check => ! check . pass ( ) ) ;
127
110
128
111
const threshold = 0 ;
129
- console . log ( ">>> failed_checks amount: " , failed_checks . length , "vs. threshold: " , threshold )
130
112
if ( failed_checks . length <= threshold )
131
113
return ;
132
114
133
115
when_suspicious ( { github, context, failed_checks} ) ;
134
- } ;
116
+ } ;
0 commit comments