diff --git a/.github/workflows/set-start-end-date-issue-status.yml b/.github/workflows/set-start-end-date-issue-status.yml index 4b2d3ab..d2d8686 100644 --- a/.github/workflows/set-start-end-date-issue-status.yml +++ b/.github/workflows/set-start-end-date-issue-status.yml @@ -23,6 +23,7 @@ jobs: ... on ProjectV2 { fields(first: 20) { nodes { + __typename # to know the type of the field ... on ProjectV2SingleSelectField { id name @@ -31,6 +32,10 @@ jobs: name } } + ... on ProjectV2Field { + id + name + } } } } @@ -42,8 +47,8 @@ jobs: // Extract the necessary field IDs dynamically const statusField = projectData.node.fields.nodes.find(field => field.name === 'Status'); - const startDateField = projectData.node.fields.nodes.find(field => field.name === 'Start Date'); - const endDateField = projectData.node.fields.nodes.find(field => field.name === 'End Date'); + const startDateField = projectData.node.fields.nodes.find(field => field.name === 'Start Date' && field.__typename === 'ProjectV2Field'); + const endDateField = projectData.node.fields.nodes.find(field => field.name === 'End Date' && field.__typename === 'ProjectV2Field'); if (!statusField || !startDateField || !endDateField) { console.log('One or more required fields (Status, Start Date, End Date) not found.'); @@ -105,7 +110,7 @@ jobs: console.log(`Issue status: ${statusFieldValue}`); // Step 3: Update Start Date for "In Progress" status - if (statusFieldValue === 'In progress') { + if (statusFieldValue === 'In Progress') { console.log(`Updating Start Date for issue ${issueNodeId}`); await github.graphql(` mutation($projectId: ID!, $itemId: ID!, $fieldId: ID!, $value: String!) { @@ -154,4 +159,4 @@ jobs: }); console.log(`End date set to ${now} for issue.`); - } \ No newline at end of file + }