Skip to content

Commit 2ee70c7

Browse files
authored
fix: Fix PR Label Check for False Positive Issues (#2537)
fixed CI Check labels and milestone script for false positive issues matching. Signed-off-by: Alfredo Gutierrez <[email protected]>
1 parent 9030cb4 commit 2ee70c7

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

.github/scripts/check-pr.js

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,22 @@ async function getPRDetails() {
1616
}
1717

1818
async function getIssueDetails(issueNumber) {
19-
const url = `https://api.github.com/repos/${owner}/${repo}/issues/${issueNumber}`;
20-
const response = await axios.get(url, {
21-
headers: {
22-
Authorization: `token ${githubToken}`
19+
try {
20+
const url = `https://api.github.com/repos/${owner}/${repo}/issues/${issueNumber}`;
21+
const response = await axios.get(url, {
22+
headers: {
23+
Authorization: `token ${githubToken}`
24+
}
25+
});
26+
return response.data;
27+
} catch (error) {
28+
if (error.response && error.response.status === 404) {
29+
console.log(`Issue #${issueNumber} not found, skipping...`);
30+
return null;
31+
} else {
32+
throw error;
2333
}
24-
});
25-
return response.data;
34+
}
2635
}
2736

2837
async function run() {
@@ -45,13 +54,15 @@ async function run() {
4554
for (const match of issueNumberMatches) {
4655
const issueNumber = match.replace('#', '');
4756
const issue = await getIssueDetails(issueNumber);
48-
const { labels: issueLabels, milestone: issueMilestone } = issue;
57+
if(issue) {
58+
const {labels: issueLabels, milestone: issueMilestone} = issue;
4959

50-
if (issueLabels.length === 0) {
51-
throw new Error(`Associated issue #${issueNumber} has no labels.`);
52-
}
53-
if (!issueMilestone) {
54-
throw new Error(`Associated issue #${issueNumber} has no milestone.`);
60+
if (issueLabels.length === 0) {
61+
throw new Error(`Associated issue #${issueNumber} has no labels.`);
62+
}
63+
if (!issueMilestone) {
64+
throw new Error(`Associated issue #${issueNumber} has no milestone.`);
65+
}
5566
}
5667
}
5768
}

0 commit comments

Comments
 (0)