Skip to content

Commit 642d5d6

Browse files
authored
fix(icr): workflow changes (#7827)
* fix(icr): workflow changes * involves Signed-off-by: Aviv Keller <[email protected]> --------- Signed-off-by: Aviv Keller <[email protected]>
1 parent be4dbf8 commit 642d5d6

File tree

2 files changed

+36
-27
lines changed

2 files changed

+36
-27
lines changed

.github/scripts/report-inactive-collaborators.mjs

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -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
1933
async 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

108113
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+
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
}

.github/workflows/find-inactive-collaborators.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ name: Find inactive collaborators
22

33
on:
44
schedule:
5-
# Run every Monday at 4:05 AM UTC.
6-
- cron: 5 4 * * 1
5+
- cron: '0 0 1 * *' # Runs at 00:00 UTC on the 1st day of every month
76

87
workflow_dispatch:
98

0 commit comments

Comments
 (0)