Skip to content

fix(icr): workflow changes #7827

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 4, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 35 additions & 25 deletions .github/scripts/report-inactive-collaborators.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@ const getDateMonthsAgo = (months = CONFIG.INACTIVE_MONTHS) => {
return date.toISOString().split('T')[0];
};

// Check if there's already an open issue
async function hasOpenIssue(github, context) {
const { owner, repo } = context.repo;
const { data: issues } = await github.rest.issues.listForRepo({
owner,
repo,
state: 'open',
labels: CONFIG.ISSUE_LABELS[1],
per_page: 1,
});

return issues.length > 0;
}

// Parse collaborator usernames from governance file
async function parseCollaborators() {
const content = await readFile(CONFIG.GOVERNANCE_FILE, 'utf8');
Expand All @@ -41,12 +55,20 @@ async function getInactiveUsers(github, usernames, repo, cutoffDate) {
const inactiveUsers = [];

for (const username of usernames) {
const { data } = await github.rest.search.commits({
// Check commits
const { data: commits } = await github.rest.search.commits({
q: `author:${username} repo:${repo} committer-date:>=${cutoffDate}`,
per_page: 1,
});

if (data.total_count === 0) {
// Check issues and PRs
const { data: issues } = await github.rest.search.issuesAndPullRequests({
q: `author:${username} repo:${repo} updated:>=${cutoffDate}`,
per_page: 1,
});

// User is inactive if they have no commits AND no issues/PRs
if (commits.total_count === 0 && issues.total_count === 0) {
inactiveUsers.push(username);
}
}
Expand Down Expand Up @@ -75,37 +97,25 @@ ${inactiveMembers.map(m => `| @${m} |`).join('\n')}
@nodejs/nodejs-website should review this list and contact inactive collaborators to confirm their continued interest in participating in the project.`;
}

async function createOrUpdateIssue(github, context, report) {
async function createIssue(github, context, report) {
if (!report) return;

const { owner, repo } = context.repo;
const { data: issues } = await github.rest.issues.listForRepo({
await github.rest.issues.create({
owner,
repo,
state: 'open',
labels: CONFIG.ISSUE_LABELS[1],
per_page: 1,
title: CONFIG.ISSUE_TITLE,
body: report,
labels: CONFIG.ISSUE_LABELS,
});

if (issues.total_count > 0) {
await github.rest.issues.update({
owner,
repo,
issue_number: issues.items[0].number,
body: report,
});
} else {
await github.rest.issues.create({
owner,
repo,
title: CONFIG.ISSUE_TITLE,
body: report,
labels: CONFIG.ISSUE_LABELS,
});
}
}

export default async function (github, context) {
// Check for existing open issue first - exit early if one exists
if (await hasOpenIssue(github, context)) {
return;
}

const cutoffDate = getDateMonthsAgo();
const collaborators = await parseCollaborators();

Expand All @@ -117,5 +127,5 @@ export default async function (github, context) {
);
const report = formatReport(inactiveMembers, cutoffDate);

await createOrUpdateIssue(github, context, report);
await createIssue(github, context, report);
}
3 changes: 1 addition & 2 deletions .github/workflows/find-inactive-collaborators.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ name: Find inactive collaborators

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

workflow_dispatch:

Expand Down
Loading