Skip to content

Commit

Permalink
feat: notify build-wg
Browse files Browse the repository at this point in the history
  • Loading branch information
marco-ippolito committed Mar 25, 2024
1 parent e47050a commit f8e33fd
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 8 deletions.
40 changes: 32 additions & 8 deletions lib/security-announcement.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import {
NEXT_SECURITY_RELEASE_REPOSITORY,
checkoutOnSecurityReleaseBranch,
getVulnerabilitiesJSON,
validateDate
validateDate,
formatDateToYYYYMMDD
} from './security-release/security-release.js';
import auth from './auth.js';
import Request from './request.js';
Expand Down Expand Up @@ -38,28 +39,51 @@ export default class SecurityAnnouncement {
validateDate(content.releaseDate);
const releaseDate = new Date(content.releaseDate);

this.createDockerNodeIssue(releaseDate);
await this.createDockerNodeIssue(releaseDate);
await this.createBuildWGIssue(releaseDate);
}

async createDockerNodeIssue(releaseDate) {
async createBuildWGIssue(releaseDate) {
const create = await this.cli.prompt(
'Create an issue in https://github.com/nodejs/docker-node to announce the security release?',
'Create an issue in the Build WG repository to announce the security release?',
{ defaultAnswer: true });

if (!create) {
this.cli.info('DockerNode issue creation skipped');
this.cli.info('BuildWG issue creation skipped');
}

const repository = {
owner: 'nodejs',
repo: 'docker-node'
repo: 'build'
};

const title = `Heads up on upcoming Node.js security\
release planned for ${releaseDate.toISOString().split('T')[0]}`;
const { title, content } = this.createPreleaseAnnouncementIssue(releaseDate);
await this.createIssue(title, content, repository);
}

createPreleaseAnnouncementIssue(releaseDate) {
const title = `[NEXT-SECURITY-RELEASE] Heads up on upcoming Node.js\
security release ${formatDateToYYYYMMDD(releaseDate)}`;
const content = 'As per security release workflow,' +
' creating issue to give docker team a heads up.';
return { title, content };
}

async createDockerNodeIssue(releaseDate) {
const create = await this.cli.prompt(
'Create an issue in the DockerNode repository to announce the security release?',
{ defaultAnswer: true });

if (!create) {
this.cli.info('DockerNode issue creation skipped');
}

const repository = {
owner: 'nodejs',
repo: 'docker-node'
};

const { title, content } = this.createPreleaseAnnouncementIssue(releaseDate);
await this.createIssue(title, content, repository);
}

Expand Down
10 changes: 10 additions & 0 deletions lib/security-release/security-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,13 @@ export function validateDate(releaseDate) {
throw new Error('Invalid date format');
}
}

export function formatDateToYYYYMMDD(date) {
// Get year, month, and day
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0'); // Months are zero-based
const day = String(date.getDate()).padStart(2, '0');

// Concatenate year, month, and day with slashes
return `${year}/${month}/${day}`;
}

0 comments on commit f8e33fd

Please sign in to comment.