Skip to content

Commit 93c54ab

Browse files
committed
feat(duplicates): run more often, skip duplicate issues
1 parent efa60e0 commit 93c54ab

File tree

5 files changed

+40
-9
lines changed

5 files changed

+40
-9
lines changed

.github/workflows/create-meeting-artifacts-scheduled.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Create Meeting Artifacts (Scheduled)
33
on:
44
workflow_dispatch:
55
schedule:
6-
- cron: '0 10 * * 1'
6+
- cron: '0 0 * * *'
77

88
jobs:
99
create-matrix:

create-node-meeting-artifacts.mjs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const program = new Command();
2121
program
2222
.argument('<group>', 'Meeting group')
2323
.option('--dry-run', 'Show output without creating/updating anything', false)
24+
.option('--force', 'Create a new issue even if one already exists', false)
2425
.option('--verbose', 'Show debug output')
2526
.parse(process.argv);
2627

@@ -77,6 +78,20 @@ const meetingTitle = meetings.generateMeetingTitle(
7778
meetingDate
7879
);
7980

81+
// Look for existing issues
82+
if (!config.force) {
83+
const existingIssue = await github.findIssueByTitle(
84+
githubClient,
85+
meetingTitle,
86+
meetingConfig
87+
);
88+
89+
if (existingIssue) {
90+
console.log(`${existingIssue.html_url} already exists. Exiting.`);
91+
process.exit(0);
92+
}
93+
}
94+
8095
// Step 9: Get agenda information using native implementation
8196
const gitHubAgendaIssues = await github.getAgendaIssues(
8297
githubClient,

src/calendar.mjs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,13 @@ export const getEventsFromCalendar = async url => {
1212
};
1313

1414
/**
15-
* @param {Date} now
15+
* @param {Date} start
1616
*/
17-
const getWeekBounds = (now = new Date()) => {
18-
const startDate = now.getUTCDate() - now.getUTCDay();
19-
20-
const start = new Date(now.setUTCDate(startDate));
17+
const getWeekBounds = (start = new Date()) => {
2118
start.setUTCHours(0, 0, 0, 0);
2219

23-
const end = new Date(now.setUTCDate(startDate + 7));
24-
end.setUTCHours(0, 0, 0, 0);
20+
const end = new Date(start);
21+
end.setUTCDate(start.getUTCDate() + 7);
2522

2623
return [start, end];
2724
};
@@ -55,7 +52,7 @@ export const findNextMeetingDate = async (allEvents, { properties }) => {
5552

5653
throw new Error(
5754
`No meeting found for ${properties.GROUP_NAME || 'this group'} ` +
58-
`in the current week (${weekStart.toISOString().split('T')[0]} to ${weekEnd.toISOString().split('T')[0]}). ` +
55+
`in the next week (${weekStart.toISOString().split('T')[0]} to ${weekEnd.toISOString().split('T')[0]}). ` +
5956
`This is expected for bi-weekly meetings or meetings that don't occur every week.`
6057
);
6158
};

src/github.mjs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,24 @@ export const sortIssuesByRepo = issues =>
5555
return obj;
5656
}, {});
5757

58+
/**
59+
* Fetches GitHub issue from a repo with a given title
60+
* @param {import('@octokit/rest').Octokit} githubClient - Authenticated GitHub API client
61+
* @param {string} title - The title to find
62+
* @param {import('./types.d.ts').MeetingConfig} meetingConfig - Meeting configuration
63+
*/
64+
export const findIssueByTitle = async (githubClient, title, { properties }) => {
65+
const githubOrg = properties.USER ?? DEFAULT_CONFIG.githubOrg;
66+
67+
const issues = await githubClient.request('GET /search/issues', {
68+
q: `is:open in:title repo:"${githubOrg}/${properties.REPO}" "${title}"`,
69+
advanced_search: true,
70+
per_page: 1,
71+
});
72+
73+
return issues.data.items[0];
74+
};
75+
5876
/**
5977
* Fetches GitHub issues from all repositories in an organization with a specific label
6078
* @param {import('@octokit/rest').Octokit} githubClient - Authenticated GitHub API client

src/types.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export interface EnvironmentConfig {
1515
*/
1616
export interface CLIConfig {
1717
verbose: boolean;
18+
force: boolean;
1819
dryRun: boolean;
1920
meetingGroup: string;
2021
}

0 commit comments

Comments
 (0)