From 9f19dfb67b3d125a982d4731264c2e4b8fab572e Mon Sep 17 00:00:00 2001 From: reinamora Date: Tue, 10 Sep 2024 11:38:38 -0500 Subject: [PATCH] chore: more debug. maybe working now :) --- .../workflows/new_discussion_to_project.yml | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/.github/workflows/new_discussion_to_project.yml b/.github/workflows/new_discussion_to_project.yml index 1a52483..725c1db 100644 --- a/.github/workflows/new_discussion_to_project.yml +++ b/.github/workflows/new_discussion_to_project.yml @@ -25,22 +25,29 @@ jobs: console.log('Event payload:', JSON.stringify(eventPayload, null, 2)); const orgLogin = eventPayload.organization.login; - const repoName = eventPayload.repository.name; const discussion = eventPayload.discussion; - console.log(`Organization: ${orgLogin}, Repository: ${repoName}, Discussion Number: ${discussion.number}`); + console.log(`Organization: ${orgLogin}, Discussion Number: ${discussion.number}`); + + const query = ` + mutation($projectId:ID!, $contentId:ID!) { + addProjectV2ItemById(input: {projectId: $projectId, contentId: $contentId}) { + item { + id + } + } + } + `; try { - // Add discussion to project - const response = await github.rest.projects.createCard({ - column_id: 'YOUR_PROJECT_COLUMN_ID', - content_id: discussion.id, - content_type: 'Discussion' + const result = await github.graphql(query, { + projectId: "3", + contentId: discussion.node_id }); - console.log('Added to project:', JSON.stringify(response.data, null, 2)); + console.log('Added to project:', JSON.stringify(result, null, 2)); - return discussion.id; + return result.addProjectV2ItemById.item.id; } catch (error) { console.error('Error:', error); throw error;