Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .github/workflows/create-meeting-artifacts-scheduled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Create Meeting Artifacts (Scheduled)
on:
workflow_dispatch:
schedule:
- cron: '0 10 * * 1'
- cron: '0 0 * * *'

jobs:
create-matrix:
Expand Down
15 changes: 15 additions & 0 deletions create-node-meeting-artifacts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const program = new Command();
program
.argument('<group>', 'Meeting group')
.option('--dry-run', 'Show output without creating/updating anything', false)
.option('--force', 'Create a new issue even if one already exists', false)
.option('--verbose', 'Show debug output')
.parse(process.argv);

Expand Down Expand Up @@ -77,6 +78,20 @@ const meetingTitle = meetings.generateMeetingTitle(
meetingDate
);

// Look for existing issues
if (!config.force) {
const existingIssue = await github.findIssueByTitle(
githubClient,
meetingTitle,
meetingConfig
);

if (existingIssue) {
console.log(`${existingIssue.html_url} already exists. Exiting.`);
process.exit(0);
}
}

// Step 9: Get agenda information using native implementation
const gitHubAgendaIssues = await github.getAgendaIssues(
githubClient,
Expand Down
13 changes: 5 additions & 8 deletions src/calendar.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,13 @@ export const getEventsFromCalendar = async url => {
};

/**
* @param {Date} now
* @param {Date} start
*/
const getWeekBounds = (now = new Date()) => {
const startDate = now.getUTCDate() - now.getUTCDay();

const start = new Date(now.setUTCDate(startDate));
const getWeekBounds = (start = new Date()) => {
start.setUTCHours(0, 0, 0, 0);

const end = new Date(now.setUTCDate(startDate + 7));
end.setUTCHours(0, 0, 0, 0);
const end = new Date(start);
end.setUTCDate(start.getUTCDate() + 7);

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

throw new Error(
`No meeting found for ${properties.GROUP_NAME || 'this group'} ` +
`in the current week (${weekStart.toISOString().split('T')[0]} to ${weekEnd.toISOString().split('T')[0]}). ` +
`in the next week (${weekStart.toISOString().split('T')[0]} to ${weekEnd.toISOString().split('T')[0]}). ` +
`This is expected for bi-weekly meetings or meetings that don't occur every week.`
);
};
18 changes: 18 additions & 0 deletions src/github.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,24 @@ export const sortIssuesByRepo = issues =>
return obj;
}, {});

/**
* Fetches GitHub issue from a repo with a given title
* @param {import('@octokit/rest').Octokit} githubClient - Authenticated GitHub API client
* @param {string} title - The title to find
* @param {import('./types.d.ts').MeetingConfig} meetingConfig - Meeting configuration
Comment thread
avivkeller marked this conversation as resolved.
*/
export const findIssueByTitle = async (githubClient, title, { properties }) => {
const githubOrg = properties.USER ?? DEFAULT_CONFIG.githubOrg;

const issues = await githubClient.request('GET /search/issues', {
q: `is:open in:title repo:"${githubOrg}/${properties.REPO}" "${title}"`,
advanced_search: true,
Comment thread
avivkeller marked this conversation as resolved.
per_page: 1,
});

return issues.data.items[0];
Comment thread
avivkeller marked this conversation as resolved.
};

/**
* Fetches GitHub issues from all repositories in an organization with a specific label
* @param {import('@octokit/rest').Octokit} githubClient - Authenticated GitHub API client
Expand Down
1 change: 1 addition & 0 deletions src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface EnvironmentConfig {
*/
export interface CLIConfig {
verbose: boolean;
force: boolean;
dryRun: boolean;
meetingGroup: string;
}
Expand Down
Loading