@@ -15,6 +15,20 @@ const getDateMonthsAgo = (months = CONFIG.INACTIVE_MONTHS) => {
1515 return date . toISOString ( ) . split ( 'T' ) [ 0 ] ;
1616} ;
1717
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+
1832// Parse collaborator usernames from governance file
1933async function parseCollaborators ( ) {
2034 const content = await readFile ( CONFIG . GOVERNANCE_FILE , 'utf8' ) ;
@@ -41,12 +55,20 @@ async function getInactiveUsers(github, usernames, repo, cutoffDate) {
4155 const inactiveUsers = [ ] ;
4256
4357 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 ( {
4560 q : `author:${ username } repo:${ repo } committer-date:>=${ cutoffDate } ` ,
4661 per_page : 1 ,
4762 } ) ;
4863
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 ) {
5072 inactiveUsers . push ( username ) ;
5173 }
5274 }
@@ -75,37 +97,25 @@ ${inactiveMembers.map(m => `| @${m} |`).join('\n')}
7597@nodejs/nodejs-website should review this list and contact inactive collaborators to confirm their continued interest in participating in the project.` ;
7698}
7799
78- async function createOrUpdateIssue ( github , context , report ) {
100+ async function createIssue ( github , context , report ) {
79101 if ( ! report ) return ;
80102
81103 const { owner, repo } = context . repo ;
82- const { data : issues } = await github . rest . issues . listForRepo ( {
104+ await github . rest . issues . create ( {
83105 owner,
84106 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 ,
88110 } ) ;
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- }
106111}
107112
108113export 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+
109119 const cutoffDate = getDateMonthsAgo ( ) ;
110120 const collaborators = await parseCollaborators ( ) ;
111121
@@ -117,5 +127,5 @@ export default async function (github, context) {
117127 ) ;
118128 const report = formatReport ( inactiveMembers , cutoffDate ) ;
119129
120- await createOrUpdateIssue ( github , context , report ) ;
130+ await createIssue ( github , context , report ) ;
121131}
0 commit comments