Skip to content

Commit a9d4268

Browse files
authored
feat: store build and docker issues when --notify-pre-release (#957)
Signed-off-by: RafaelGSS <[email protected]>
1 parent 0bafa24 commit a9d4268

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

lib/security-announcement.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
import fs from 'node:fs';
12
import {
23
NEXT_SECURITY_RELEASE_REPOSITORY,
34
checkoutOnSecurityReleaseBranch,
45
getVulnerabilitiesJSON,
6+
getVulnerabilitiesJSONPath,
57
validateDate,
68
formatDateToYYYYMMDD,
9+
commitAndPushVulnerabilitiesJSON,
710
createIssue
811
} from './security-release/security-release.js';
912
import auth from './auth.js';
@@ -40,10 +43,21 @@ export default class SecurityAnnouncement {
4043
validateDate(content.releaseDate);
4144
const releaseDate = new Date(content.releaseDate);
4245

43-
await Promise.all([
46+
const [dockerIssue, buildIssue] = await Promise.all([
4447
this.createDockerNodeIssue(releaseDate),
4548
this.createBuildWGIssue(releaseDate)
4649
]);
50+
51+
content.buildIssue = buildIssue;
52+
content.dockerIssue = dockerIssue;
53+
54+
const vulnerabilitiesJSONPath = getVulnerabilitiesJSONPath();
55+
fs.writeFileSync(vulnerabilitiesJSONPath, JSON.stringify(content, null, 2));
56+
const commitMessage = 'chore: add build and docker issue link';
57+
commitAndPushVulnerabilitiesJSON([vulnerabilitiesJSONPath],
58+
commitMessage, { cli: this.cli, repository: this.repository });
59+
60+
this.cli.ok('Added docker and build issue in vulnerabilities.json');
4761
}
4862

4963
async createBuildWGIssue(releaseDate) {
@@ -53,7 +67,7 @@ export default class SecurityAnnouncement {
5367
};
5468

5569
const { title, content } = this.createPreleaseAnnouncementIssue(releaseDate, 'build');
56-
await createIssue(title, content, repository, { cli: this.cli, req: this.req });
70+
return createIssue(title, content, repository, { cli: this.cli, req: this.req });
5771
}
5872

5973
createPreleaseAnnouncementIssue(releaseDate, team) {
@@ -71,6 +85,6 @@ export default class SecurityAnnouncement {
7185
};
7286

7387
const { title, content } = this.createPreleaseAnnouncementIssue(releaseDate, 'docker');
74-
await createIssue(title, content, repository, { cli: this.cli, req: this.req });
88+
return createIssue(title, content, repository, { cli: this.cli, req: this.req });
7589
}
7690
}

lib/security-release/security-release.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ export function getVulnerabilitiesJSON(cli) {
107107
return file;
108108
}
109109

110+
export function getVulnerabilitiesJSONPath() {
111+
const vulnerabilitiesJSONPath = path.join(process.cwd(),
112+
NEXT_SECURITY_RELEASE_FOLDER, 'vulnerabilities.json');
113+
return vulnerabilitiesJSONPath;
114+
}
115+
110116
export function validateDate(releaseDate) {
111117
const value = new Date(releaseDate).valueOf();
112118
if (Number.isNaN(value) || value < 0) {
@@ -135,6 +141,7 @@ export async function createIssue(title, content, repository, { cli, req }) {
135141
const data = await req.createIssue(title, content, repository);
136142
if (data.html_url) {
137143
cli.ok(`Created: ${data.html_url}`);
144+
return data.html_url;
138145
} else {
139146
cli.error(data);
140147
process.exit(1);

0 commit comments

Comments
 (0)