diff --git a/.github/workflows/issue_triage.yml b/.github/workflows/issue_triage.yml index d47bf0774e5..f670c5bfe66 100644 --- a/.github/workflows/issue_triage.yml +++ b/.github/workflows/issue_triage.yml @@ -20,24 +20,13 @@ jobs: repository(owner: $owner, name: $repo) { issue(number: $issueNumber) { number - projectV2Items(first: 10) { # Changed from projectItems to projectV2Items + projectsV2(first: 10) { nodes { id - project { - title - id - } - fieldValues(first: 8) { + title + items(first: 1) { nodes { - ... on ProjectV2ItemFieldSingleSelectValue { - name - field { - ... on ProjectV2SingleSelectField { - id - name - } - } - } + id } } } @@ -54,7 +43,7 @@ jobs: }; const result = await github.graphql(query, variables); - const projects = result.repository.issue.projectV2Items.nodes; + const projects = result.repository.issue.projectsV2.nodes; if (projects.length !== 1) { const message = `This issue must belong to exactly one project. Currently assigned to ${projects.length} project(s).`; @@ -66,10 +55,24 @@ jobs: }); core.setOutput('projectValid', 'false'); } else { + const project = projects[0]; + const itemId = project.items.nodes[0]?.id; + + if (!itemId) { + core.setOutput('projectValid', 'false'); + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body: 'Could not find issue in project.' + }); + return; + } + core.setOutput('projectValid', 'true'); - core.setOutput('projectTitle', projects[0].project.title); - core.setOutput('projectId', projects[0].project.id); - core.setOutput('itemId', projects[0].id); + core.setOutput('projectTitle', project.title); + core.setOutput('projectId', project.id); + core.setOutput('itemId', itemId); } - name: Move Issue to "In Progress" on Self-Assignment @@ -77,20 +80,16 @@ jobs: uses: actions/github-script@v6 with: script: | - // First, get the status field ID const statusFieldQuery = ` query($projectId: ID!) { node(id: $projectId) { ... on ProjectV2 { - fields(first: 20) { - nodes { - ... on ProjectV2SingleSelectField { + field(name: "Status") { + ... on ProjectV2SingleSelectField { + id + options { id name - options { - id - name - } } } } @@ -100,17 +99,14 @@ jobs: `; const statusResult = await github.graphql(statusFieldQuery, { - projectId: steps.check-projects.outputs.projectId + projectId: "${{ steps.check-projects.outputs.projectId }}" }); - const statusField = statusResult.node.fields.nodes.find( - field => field.name.toLowerCase() === 'status' - ); - - if (!statusField) { + if (!statusResult.node?.field) { throw new Error('Status field not found in project'); } + const statusField = statusResult.node.field; const inProgressOption = statusField.options.find( option => option.name.toLowerCase() === 'in progress' ); @@ -119,9 +115,8 @@ jobs: throw new Error('In Progress status option not found'); } - // Update the status await github.graphql(` - mutation($itemId: ID!, $projectId: ID!, $fieldId: ID!, $optionId: String!) { + mutation($projectId: ID!, $itemId: ID!, $fieldId: ID!, $optionId: String!) { updateProjectV2ItemFieldValue( input: { projectId: $projectId @@ -138,8 +133,8 @@ jobs: } } `, { - itemId: steps.check-projects.outputs.itemId, - projectId: steps.check-projects.outputs.projectId, + projectId: "${{ steps.check-projects.outputs.projectId }}", + itemId: "${{ steps.check-projects.outputs.itemId }}", fieldId: statusField.id, optionId: inProgressOption.id });