@@ -13,12 +13,12 @@ jobs:
1313 github-token : ${{ secrets.PERSONAL_GITHUB_TOKEN }}
1414 script : |
1515 const issue = context.payload.issue;
16- const labels = issue.labels.map(l => l.name.toLowerCase() );
16+ const labels = issue.labels.map(l => l.name);
1717
1818 const projectId = "PVT_kwHOAclbns4AqfIH"; // Petlibro Project ID
1919
2020 // Only process your templates
21- const allowedLabels = ["bug ", "feature request ", "new device "];
21+ const allowedLabels = ["Bug ", "Feature Request ", "New Device "];
2222 if (!labels.some(l => allowedLabels.includes(l))) {
2323 console.log("Skipping — issue does not match your templates.");
2424 return;
@@ -67,69 +67,73 @@ jobs:
6767 }
6868
6969 // 2️⃣ Set Priority
70- const priorityFieldId = "PVTSSF_lAHOAclbns4AqfIHzghudTQ";
71- const priorityOptions = {
72- "Critical": "79628723",
73- "High": "0a877460",
74- "Medium": "da944a9c",
75- "Low": "0b6337eb",
76- "Deferred": "9d531ad0",
77- "Completed": "20ffdcc8"
78- };
79-
80- let priorityValue = "Medium"; // default
81- if (labels.includes("bug")) priorityValue = "High";
82- else if (labels.includes("feature request")) priorityValue = "Medium";
83- else if (labels.includes("new device")) priorityValue = "Low";
84-
85- console.log(`Setting Priority to ${priorityValue} (ID: ${priorityOptions[priorityValue]})`);
8670 try {
71+ const priorityFieldId = "PVTSSF_lAHOAclbns4AqfIHzghudTQ";
72+ const priorityOptions = {
73+ "Critical": "79628723",
74+ "High": "0a877460",
75+ "Medium": "da944a9c",
76+ "Low": "0b6337eb",
77+ "Deferred": "9d531ad0",
78+ "Completed": "20ffdcc8"
79+ };
80+
81+ let priorityValue = "Medium";
82+ if (labels.includes("Bug")) priorityValue = "High";
83+ else if (labels.includes("Feature Request")) priorityValue = "Medium";
84+ else if (labels.includes("New Device")) priorityValue = "Low";
85+
86+ console.log(`Setting Priority to ${priorityValue} (ID: ${priorityOptions[priorityValue]})`);
8787 await github.graphql(`
88- mutation($itemId: ID!, $fieldId: ID!, $optionId: String!) {
88+ mutation($projectId: ID!, $ itemId: ID!, $fieldId: ID!, $optionId: String!) {
8989 updateProjectV2ItemFieldValue(input: {
90+ projectId: $projectId,
9091 itemId: $itemId,
9192 fieldId: $fieldId,
9293 value: { singleSelectOptionId: $optionId }
9394 }) {
94- item { id }
95+ projectV2Item { id }
9596 }
9697 }
97- `, { itemId, fieldId: priorityFieldId, optionId: priorityOptions[priorityValue] });
98+ `, { projectId, itemId, fieldId: priorityFieldId, optionId: priorityOptions[priorityValue] });
99+
98100 console.log(`✅ Set Priority to ${priorityValue}`);
99101 } catch (error) {
100102 console.error("Error setting Priority:", error);
101103 }
102104
103- // 3️⃣ Set Status
104- const statusFieldId = "PVTSSF_lAHOAclbns4AqfIHzghucgA";
105- const statusOptions = {
106- "To triage": "f971fb55",
107- "Pending": "f75ad846",
108- "Ready": "856cdede",
109- "In progress": "47fc9ee4",
110- "In review": "5ef0dc97",
111- "Deferred": "e0243c67",
112- "Done": "98236657"
113- };
114-
115- let statusValue = "To triage"; // default
116- if (labels.includes("bug")) statusValue = "Pending";
117- else if (labels.includes("feature request")) statusValue = "To triage";
118- else if (labels.includes("new device")) statusValue = "Ready";
119-
120- console.log(`Setting Status to ${statusValue} (ID: ${statusOptions[statusValue]})`);
105+ // 3️⃣ Set Status dynamically
121106 try {
107+ const statusFieldId = "PVTSSF_lAHOAclbns4AqfIHzghucgA";
108+ const statusOptions = {
109+ "To triage": "f971fb55",
110+ "Pending": "f75ad846",
111+ "Ready": "856cdede",
112+ "In progress": "47fc9ee4",
113+ "In review": "5ef0dc97",
114+ "Deferred": "e0243c67",
115+ "Done": "98236657"
116+ };
117+
118+ let statusValue = "To triage"; // default
119+ if (labels.includes("Bug")) statusValue = "Pending";
120+ else if (labels.includes("Feature Request")) statusValue = "To triage";
121+ else if (labels.includes("New Device")) statusValue = "Ready";
122+
123+ console.log(`Setting Status to ${statusValue} (ID: ${statusOptions[statusValue]})`);
122124 await github.graphql(`
123- mutation($itemId: ID!, $fieldId: ID!, $optionId: String!) {
125+ mutation($projectId: ID!, $ itemId: ID!, $fieldId: ID!, $optionId: String!) {
124126 updateProjectV2ItemFieldValue(input: {
127+ projectId: $projectId,
125128 itemId: $itemId,
126129 fieldId: $fieldId,
127130 value: { singleSelectOptionId: $optionId }
128131 }) {
129- item { id }
132+ projectV2Item { id }
130133 }
131134 }
132- `, { itemId, fieldId: statusFieldId, optionId: statusOptions[statusValue] });
135+ `, { projectId, itemId, fieldId: statusFieldId, optionId: statusOptions[statusValue] });
136+
133137 console.log(`✅ Set Status to ${statusValue}`);
134138 } catch (error) {
135139 console.error("Error setting Status:", error);
0 commit comments