Skip to content

Commit

Permalink
chore: for global project settings
Browse files Browse the repository at this point in the history
  • Loading branch information
reinamora137 committed Sep 10, 2024
1 parent f403370 commit 0fc6b85
Showing 1 changed file with 4 additions and 29 deletions.
33 changes: 4 additions & 29 deletions .github/workflows/new_discussion_to_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ jobs:
console.log(`Organization: ${orgLogin}, Project Number: ${projectNumber}`);
console.log('Discussion URL:', context.payload.discussion.html_url);
console.log('Discussion node_id:', context.payload.discussion.node_id);
console.log('Discussion repository:', context.payload.repository.full_name);
// First, get the project ID
const getProjectIdQuery = `
Expand All @@ -53,10 +52,10 @@ jobs:
throw error;
}
// Now, add the discussion to the project
// Now, add the discussion to the project using its URL
const addToProjectMutation = `
mutation($projectId: ID!, $contentId: ID!) {
addProjectV2ItemById(input: {projectId: $projectId, contentId: $contentId}) {
mutation($projectId: ID!, $url: String!) {
addProjectV2ItemByUrl(input: {projectId: $projectId, url: $url}) {
item {
id
}
Expand All @@ -68,7 +67,7 @@ jobs:
console.log('Adding discussion to project...');
const result = await github.graphql(addToProjectMutation, {
projectId: projectId,
contentId: context.payload.discussion.node_id
url: context.payload.discussion.html_url
});
console.log('Added to project:', JSON.stringify(result, null, 2));
Expand All @@ -81,29 +80,5 @@ jobs:
// Additional error information
console.log('Full context payload:', JSON.stringify(context.payload, null, 2));
// Fetch discussion details using GraphQL
const getDiscussionQuery = `
query($owner: String!, $repo: String!, $number: Int!) {
repository(owner: $owner, name: $repo) {
discussion(number: $number) {
id
title
url
}
}
}
`;
try {
const discussionData = await github.graphql(getDiscussionQuery, {
owner: context.payload.organization.login,
repo: context.payload.repository.name,
number: context.payload.discussion.number
});
console.log('Discussion details:', JSON.stringify(discussionData, null, 2));
} catch (discussionError) {
console.error('Error fetching discussion details:', discussionError);
}
throw error;
}

0 comments on commit 0fc6b85

Please sign in to comment.