@@ -42,6 +42,46 @@ export const createGitHubIssue = async (
4242 return response . data ;
4343} ;
4444
45+ /**
46+ * Creates or updates a GitHub issue with meeting information and Google Doc link
47+ * @param {import('@octokit/rest').Octokit } githubClient - Authenticated GitHub API client
48+ * @param {import('./types.d.ts').AppConfig } config - The application config
49+ * @param {import('./types.d.ts').MeetingConfig } meetingConfig - Meeting configuration object
50+ * @param {string } title - Issue title
51+ * @param {string } content - Issue content
52+ * @returns {Promise<GitHubIssue> } Created issue data
53+ */
54+ export const createOrUpdateGitHubIssue = async (
55+ githubClient ,
56+ { force } ,
57+ meetingConfig ,
58+ title ,
59+ content
60+ ) => {
61+ if ( ! force ) {
62+ const existingIssue = await findGitHubIssueByTitle (
63+ githubClient ,
64+ title ,
65+ meetingConfig
66+ ) ;
67+
68+ if ( existingIssue ) {
69+ if ( content !== existingIssue . body ) {
70+ await updateGitHubIssue (
71+ githubClient ,
72+ existingIssue . number ,
73+ content ,
74+ meetingConfig
75+ ) ;
76+ }
77+
78+ return existingIssue ;
79+ }
80+ }
81+
82+ return createGitHubIssue ( githubClient , meetingConfig , title , content ) ;
83+ } ;
84+
4585/**
4686 * Sorts issues by repository
4787 * @param {Array<GitHubIssue> } issues The issues to sort
@@ -55,13 +95,40 @@ export const sortIssuesByRepo = issues =>
5595 return obj ;
5696 } , { } ) ;
5797
98+ /**
99+ * Updates an existing GitHub issue with new content
100+ * @param {import('@octokit/rest').Octokit } githubClient - Authenticated GitHub API client
101+ * @param {number } number - The issue number
102+ * @param {string } content - The new content
103+ * @param {import('./types.d.ts').MeetingConfig } meetingConfig - Meeting configuration
104+ */
105+ export const updateGitHubIssue = async (
106+ githubClient ,
107+ number ,
108+ content ,
109+ { properties }
110+ ) => {
111+ const githubOrg = properties . USER ?? DEFAULT_CONFIG . githubOrg ;
112+
113+ return githubClient . issues . update ( {
114+ issue_number : number ,
115+ body : content ,
116+ owner : githubOrg ,
117+ repo : properties . REPO ,
118+ } ) ;
119+ } ;
120+
58121/**
59122 * Fetches GitHub issue from a repo with a given title
60123 * @param {import('@octokit/rest').Octokit } githubClient - Authenticated GitHub API client
61124 * @param {string } title - The title to find
62125 * @param {import('./types.d.ts').MeetingConfig } meetingConfig - Meeting configuration
63126 */
64- export const findIssueByTitle = async ( githubClient , title , { properties } ) => {
127+ export const findGitHubIssueByTitle = async (
128+ githubClient ,
129+ title ,
130+ { properties }
131+ ) => {
65132 const githubOrg = properties . USER ?? DEFAULT_CONFIG . githubOrg ;
66133
67134 const issues = await githubClient . request ( 'GET /search/issues' , {
0 commit comments