@@ -355,6 +355,19 @@ async function createGithubIssue(
355355 } ,
356356 }
357357 ) ;
358+
359+ const issueNodeId = response . data . node_id ;
360+ const projectId = "PVT_kwDOAnHxDs4Ayxl6" ;
361+ const statusFieldId = "PVTSSF_lADOAnHxDs4Ayxl6zgorIUI" ;
362+ const backlogOptionId = "8e14ac56" ;
363+ await addIssueToProjectV2 (
364+ issueNodeId ,
365+ githubToken ,
366+ projectId ,
367+ statusFieldId ,
368+ backlogOptionId
369+ ) ;
370+
358371 return response . data . html_url ;
359372 } catch ( error ) {
360373 logger . error ( "Error creating GitHub issue:" , error ) ;
@@ -485,4 +498,88 @@ async function isValidZipDownload(url: string | undefined | null): Promise<boole
485498 } catch {
486499 return false ;
487500 }
501+ }
502+
503+ /**
504+ * Adds a GitHub issue to a project with a specific status
505+ * @param {string } issueNodeId The ID of the created issue
506+ * @param {string } githubToken GitHub token
507+ * @param {string } projectId The ID of the project
508+ * @param {string } statusFieldId The ID of the Status field
509+ * @param {string } statusOptionId The ID of the status option
510+ */
511+ async function addIssueToProjectV2 (
512+ issueNodeId : string ,
513+ githubToken : string ,
514+ projectId : string ,
515+ statusFieldId : string ,
516+ statusOptionId : string
517+ ) {
518+ try {
519+ const addToProjectMutation = `
520+ mutation($projectId: ID!, $contentId: ID!) {
521+ addProjectV2ItemById(input: {projectId: $projectId, contentId: $contentId}) {
522+ item {
523+ id
524+ }
525+ }
526+ }
527+ ` ;
528+
529+ const addToProjectResponse = await axios . post (
530+ "https://api.github.com/graphql" ,
531+ {
532+ query : addToProjectMutation ,
533+ variables : {
534+ projectId,
535+ contentId : issueNodeId ,
536+ } ,
537+ } ,
538+ {
539+ headers : {
540+ Authorization : `bearer ${ githubToken } ` ,
541+ Accept : "application/vnd.github.v3+json" ,
542+ } ,
543+ }
544+ ) ;
545+
546+ const itemId = addToProjectResponse . data . data . addProjectV2ItemById . item . id ;
547+
548+ const updateStatusMutation = `
549+ mutation($projectId: ID!, $itemId: ID!, $fieldId: ID!, $value: ProjectV2FieldValue!) {
550+ updateProjectV2ItemFieldValue(
551+ input: {projectId: $projectId, itemId: $itemId, fieldId: $fieldId, value: $value}
552+ ) {
553+ projectV2Item {
554+ id
555+ }
556+ }
557+ }
558+ ` ;
559+
560+ await axios . post (
561+ "https://api.github.com/graphql" ,
562+ {
563+ query : updateStatusMutation ,
564+ variables : {
565+ projectId,
566+ itemId,
567+ fieldId : statusFieldId ,
568+ value : {
569+ singleSelectOptionId : statusOptionId ,
570+ } ,
571+ } ,
572+ } ,
573+ {
574+ headers : {
575+ Authorization : `bearer ${ githubToken } ` ,
576+ Accept : "application/vnd.github.v3+json" ,
577+ } ,
578+ }
579+ ) ;
580+
581+ logger . info ( "Successfully added issue to Feed Submissions Backlog" ) ;
582+ } catch ( error ) {
583+ logger . error ( "Error adding issue to Feed Submissions Backlog:" , error ) ;
584+ }
488585}
0 commit comments