Skip to content

Commit

Permalink
feat: use sec release template in PR description (#832)
Browse files Browse the repository at this point in the history
* feat: use sec release template in PR description

* fixup! feat: use sec release template in PR description
  • Loading branch information
RafaelGSS committed Jul 29, 2024
1 parent 88c31eb commit 25ea992
Showing 1 changed file with 8 additions and 18 deletions.
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

0 comments on commit 25ea992

Please sign in to comment.