Skip to content

Commit 3485d67

Browse files
committed
Also create comment for commits that close an issue
1 parent 24d8131 commit 3485d67

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

.github/workflows/integration.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,14 @@ jobs:
3636
const commits = context.payload.commits || [];
3737
const messages = commits.map(commit => commit.message).join('\n');
3838
const issueRefs = messages.match(/#(\d+)/g) || [];
39-
const issues = [...new Set(issueRefs.map(ref => parseInt(ref.slice(1))))];
39+
const issues = new Set(issueRefs.map(ref => parseInt(ref.slice(1))));
40+
const isClosingMatch = /(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\s+#(\d+)/gi;
41+
const closingIssues = new Set([...messages.matchAll(isClosingMatch)].map(m => parseInt(m[1])));
4042
for (const issue_number of issues) {
4143
try {
4244
const { owner, repo } = context.repo;
4345
const { data } = await github.rest.issues.get({ owner, repo, issue_number });
44-
if (data.state === 'open') {
46+
if (data.state === 'open' || closingIssues.has(issue_number)) {
4547
const body = `Preview release available:\n\`\`\`sh\nnpm i -D https://pkg.pr.new/knip@${sha}\n\`\`\``;
4648
await github.rest.issues.createComment({ owner, repo, issue_number, body });
4749
}

0 commit comments

Comments
 (0)