@@ -15,6 +15,20 @@ const getDateMonthsAgo = (months = CONFIG.INACTIVE_MONTHS) => {
15
15
return date . toISOString ( ) . split ( 'T' ) [ 0 ] ;
16
16
} ;
17
17
18
+ // Check if there's already an open issue
19
+ async function hasOpenIssue ( github , context ) {
20
+ const { owner, repo } = context . repo ;
21
+ const { data : issues } = await github . rest . issues . listForRepo ( {
22
+ owner,
23
+ repo,
24
+ state : 'open' ,
25
+ labels : CONFIG . ISSUE_LABELS [ 1 ] ,
26
+ per_page : 1 ,
27
+ } ) ;
28
+
29
+ return issues . length > 0 ;
30
+ }
31
+
18
32
// Parse collaborator usernames from governance file
19
33
async function parseCollaborators ( ) {
20
34
const content = await readFile ( CONFIG . GOVERNANCE_FILE , 'utf8' ) ;
@@ -41,12 +55,20 @@ async function getInactiveUsers(github, usernames, repo, cutoffDate) {
41
55
const inactiveUsers = [ ] ;
42
56
43
57
for ( const username of usernames ) {
44
- const { data } = await github . rest . search . commits ( {
58
+ // Check commits
59
+ const { data : commits } = await github . rest . search . commits ( {
45
60
q : `author:${ username } repo:${ repo } committer-date:>=${ cutoffDate } ` ,
46
61
per_page : 1 ,
47
62
} ) ;
48
63
49
- if ( data . total_count === 0 ) {
64
+ // Check issues and PRs
65
+ const { data : issues } = await github . rest . search . issuesAndPullRequests ( {
66
+ q : `involves:${ username } repo:${ repo } updated:>=${ cutoffDate } ` ,
67
+ per_page : 1 ,
68
+ } ) ;
69
+
70
+ // User is inactive if they have no commits AND no issues/PRs
71
+ if ( commits . total_count === 0 && issues . total_count === 0 ) {
50
72
inactiveUsers . push ( username ) ;
51
73
}
52
74
}
@@ -75,37 +97,25 @@ ${inactiveMembers.map(m => `| @${m} |`).join('\n')}
75
97
@nodejs/nodejs-website should review this list and contact inactive collaborators to confirm their continued interest in participating in the project.` ;
76
98
}
77
99
78
- async function createOrUpdateIssue ( github , context , report ) {
100
+ async function createIssue ( github , context , report ) {
79
101
if ( ! report ) return ;
80
102
81
103
const { owner, repo } = context . repo ;
82
- const { data : issues } = await github . rest . issues . listForRepo ( {
104
+ await github . rest . issues . create ( {
83
105
owner,
84
106
repo,
85
- state : 'open' ,
86
- labels : CONFIG . ISSUE_LABELS [ 1 ] ,
87
- per_page : 1 ,
107
+ title : CONFIG . ISSUE_TITLE ,
108
+ body : report ,
109
+ labels : CONFIG . ISSUE_LABELS ,
88
110
} ) ;
89
-
90
- if ( issues . total_count > 0 ) {
91
- await github . rest . issues . update ( {
92
- owner,
93
- repo,
94
- issue_number : issues . items [ 0 ] . number ,
95
- body : report ,
96
- } ) ;
97
- } else {
98
- await github . rest . issues . create ( {
99
- owner,
100
- repo,
101
- title : CONFIG . ISSUE_TITLE ,
102
- body : report ,
103
- labels : CONFIG . ISSUE_LABELS ,
104
- } ) ;
105
- }
106
111
}
107
112
108
113
export default async function ( github , context ) {
114
+ // Check for existing open issue first - exit early if one exists
115
+ if ( await hasOpenIssue ( github , context ) ) {
116
+ return ;
117
+ }
118
+
109
119
const cutoffDate = getDateMonthsAgo ( ) ;
110
120
const collaborators = await parseCollaborators ( ) ;
111
121
@@ -117,5 +127,5 @@ export default async function (github, context) {
117
127
) ;
118
128
const report = formatReport ( inactiveMembers , cutoffDate ) ;
119
129
120
- await createOrUpdateIssue ( github , context , report ) ;
130
+ await createIssue ( github , context , report ) ;
121
131
}
0 commit comments