Skip to content

Commit ee6c177

Browse files
committed
update workflow in response to review
1 parent 7d7b29c commit ee6c177

2 files changed

Lines changed: 27 additions & 7 deletions

File tree

.github/workflows/check-closed-issue-for-linked-pr.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- name: Check Out Repository
12-
uses: actions/checkout@v4
12+
uses: actions/checkout@v6
1313

1414
- name: Check Issue Labels And Linked PRs
1515
uses: actions/github-script@v8
@@ -23,9 +23,6 @@ jobs:
2323
+ '/check-issue-labels-and-linked-prs.js'
2424
);
2525
const isValidClose = await script({github, context});
26-
console.log(
27-
`Issue is ${isValidClose ? '' : 'not '}allowed to be closed.`
28-
);
2926
core.setOutput('isValidClose', isValidClose);
3027
3128
- name: Reopen Issue

github-actions/check-closed-issue-for-linked-pr/check-for-linked-issue/check-issue-labels-and-linked-prs.js

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
const retrieveLabelDirectory = require('../../utils/retrieve-label-directory');
2+
3+
// Use labelKeys to retrieve current labelNames from directory
4+
const [
5+
nonPrContribution
6+
] = [
7+
'NEW-nonPrContribution'
8+
].map(retrieveLabelDirectory);
9+
10+
// ==================================================
11+
112
/**
213
* Checks whether a closed issue has a linked PR or one of the labels to excuse
314
* this GitHub Actions workflow.
@@ -14,15 +25,22 @@ async function hasLinkedPrOrExcusableLabel({ github, context }) {
1425

1526
const labels = context.payload.issue.labels.map((label) => label.name);
1627

28+
const consoleMessageAllowClose =
29+
`Issue #${issueNumber} is allowed to be closed.`;
30+
1731
// --------------------------------------------------
1832

1933
// Check if the issue has the labels that will avoid re-opening it.
2034
if (
2135
labels.some(
22-
(label) => label === 'non-PR contribution' || label.includes('Ignore')
36+
(label) =>
37+
label === nonPrContribution || label.toLowerCase().includes('ignore')
2338
)
24-
)
39+
) {
40+
console.info(consoleMessageAllowClose);
2541
return true;
42+
}
43+
2644
console.info(
2745
`Issue #${issueNumber} does not have ` +
2846
`the necessary labels to excuse reopening it.`
@@ -46,6 +64,7 @@ async function hasLinkedPrOrExcusableLabel({ github, context }) {
4664
issue: issueNumber,
4765
};
4866

67+
// Determine if there is a linked PR.
4968
try {
5069
const response = await github.graphql(query, variables);
5170

@@ -54,7 +73,10 @@ async function hasLinkedPrOrExcusableLabel({ github, context }) {
5473

5574
console.debug(`Number of linked PRs found: ${numLinkedPrs}.`);
5675

57-
if (numLinkedPrs > 0) return true;
76+
if (numLinkedPrs > 0) {
77+
console.info(consoleMessageAllowClose);
78+
return true;
79+
}
5880
} catch (err) {
5981
throw new Error(
6082
`Can not find issue #${issueNumber} or its PR count; error = ${err}`
@@ -63,6 +85,7 @@ async function hasLinkedPrOrExcusableLabel({ github, context }) {
6385
console.info(`Issue #${issueNumber} does not have a linked PR.`);
6486

6587
// If the issue does not have a linked PR or any of the excusable labels.
88+
console.info(`Issue #${issueNumber} is not allowed to be closed.`);
6689
return false;
6790
}
6891

0 commit comments

Comments
 (0)