Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use sec release template in PR description #832

Merged
merged 2 commits into from
Jul 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 8 additions & 18 deletions lib/prepare_security.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
NEXT_SECURITY_RELEASE_BRANCH,
NEXT_SECURITY_RELEASE_FOLDER,
NEXT_SECURITY_RELEASE_REPOSITORY,
PLACEHOLDERS,
checkoutOnSecurityReleaseBranch,
commitAndPushVulnerabilitiesJSON,
validateDate,
Expand Down Expand Up @@ -37,22 +36,15 @@ export default class PrepareSecurityRelease {
const createVulnerabilitiesJSON = await this.promptVulnerabilitiesJSON();

let securityReleasePRUrl;
const content = await this.buildDescription(releaseDate, securityReleasePRUrl);
if (createVulnerabilitiesJSON) {
securityReleasePRUrl = await this.startVulnerabilitiesJSONCreation(releaseDate);
securityReleasePRUrl = await this.startVulnerabilitiesJSONCreation(releaseDate, content);
}

const createIssue = await this.promptCreateRelaseIssue();

if (createIssue) {
const content = await this.buildIssue(releaseDate, securityReleasePRUrl);
await createIssue(
this.title, content, this.repository, { cli: this.cli, repository: this.repository });
};

this.cli.ok('Done!');
}

async startVulnerabilitiesJSONCreation(releaseDate) {
async startVulnerabilitiesJSONCreation(releaseDate, content) {
// checkout on the next-security-release branch
checkoutOnSecurityReleaseBranch(this.cli, this.repository);

Expand Down Expand Up @@ -87,7 +79,7 @@ export default class PrepareSecurityRelease {
if (!createPr) return;

// create pr on the security-release repo
return this.createPullRequest();
return this.createPullRequest(content);
}

promptCreatePR() {
Expand Down Expand Up @@ -143,11 +135,9 @@ export default class PrepareSecurityRelease {
{ defaultAnswer: true });
}

async buildIssue(releaseDate, securityReleasePRUrl = PLACEHOLDERS.vulnerabilitiesPRURL) {
async buildDescription() {
const template = await this.getSecurityIssueTemplate();
const content = template.replace(PLACEHOLDERS.releaseDate, releaseDate)
.replace(PLACEHOLDERS.vulnerabilitiesPRURL, securityReleasePRUrl);
return content;
return template;
}

async chooseReports() {
Expand Down Expand Up @@ -185,11 +175,11 @@ export default class PrepareSecurityRelease {
return fullPath;
}

async createPullRequest() {
async createPullRequest(content) {
const { owner, repo } = this.repository;
const response = await this.req.createPullRequest(
this.title,
'List of vulnerabilities to be included in the next security release',
content ?? 'List of vulnerabilities to be included in the next security release',
{
owner,
repo,
Expand Down
Loading