Skip to content

Commit 706e363

Browse files
committed
Ensures re-opened issues are updated
1 parent e7ace49 commit 706e363

2 files changed

Lines changed: 29 additions & 9 deletions

File tree

.github/actions/file/src/index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,13 @@ export default async function () {
6464
response = await openIssue(octokit, repoWithOwner, filing.findings[0]);
6565
(filing as any).issue = { state: "open" } as Issue;
6666
} else if (isRepeatedFiling(filing)) {
67-
// Reopen the filing’s issue (if necessary)
68-
response = await reopenIssue(octokit, new Issue(filing.issue));
67+
// Reopen the filing's issue (if necessary) and update the body with the latest finding
68+
response = await reopenIssue(
69+
octokit,
70+
new Issue(filing.issue),
71+
filing.findings[0],
72+
repoWithOwner,
73+
);
6974
filing.issue.state = "reopened";
7075
}
7176
if (response?.data && filing.issue) {
Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
11
import type { Octokit } from '@octokit/core';
22
import type { Issue } from './Issue.js';
3+
import type { Finding } from "./types.d.js";
4+
import { generateIssueBody } from "./generateIssueBody.js";
35

4-
export async function reopenIssue(octokit: Octokit, { owner, repository, issueNumber}: Issue) {
5-
return octokit.request(`PATCH /repos/${owner}/${repository}/issues/${issueNumber}`, {
6-
owner,
7-
repository,
8-
issue_number: issueNumber,
9-
state: 'open'
10-
});
6+
export async function reopenIssue(
7+
octokit: Octokit,
8+
{ owner, repository, issueNumber }: Issue,
9+
finding?: Finding,
10+
repoWithOwner?: string,
11+
) {
12+
const body =
13+
finding && repoWithOwner
14+
? generateIssueBody(finding, repoWithOwner)
15+
: undefined;
16+
return octokit.request(
17+
`PATCH /repos/${owner}/${repository}/issues/${issueNumber}`,
18+
{
19+
owner,
20+
repository,
21+
issue_number: issueNumber,
22+
state: "open",
23+
...(body ? { body } : {}),
24+
},
25+
);
1126
}

0 commit comments

Comments
 (0)