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

[NoQA] FIX / ProposalPolice™ GH Actions Workflow - Get date from workflow run #47529

Merged
merged 1 commit into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions .github/actions/javascript/proposalPoliceComment/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17987,6 +17987,8 @@ function isCommentCreatedEvent(payload) {
}
// Main function to process the workflow event
async function run() {
// get date early, as soon as the workflow starts running
const date = new Date();
// Verify this is running for an expected webhook event
if (github_1.context.eventName !== CONST_1.default.EVENTS.ISSUE_COMMENT) {
throw new Error('ProposalPolice™ only supports the issue_comment webhook event');
Expand Down Expand Up @@ -18046,8 +18048,7 @@ async function run() {
// extract the text after [EDIT_COMMENT] from assistantResponse since this is a
// bot related action keyword
let extractedNotice = assistantResponse.split('[EDIT_COMMENT] ')?.[1]?.replace('"', '');
// format the github's updated_at like: 2024-01-24 13:15:24 UTC not 2024-01-28 18:18:28.000 UTC
const date = new Date(payload.comment?.updated_at ?? '');
// format the date like: 2024-01-24 13:15:24 UTC not 2024-01-28 18:18:28.000 UTC
const formattedDate = `${date.toISOString()?.split('.')?.[0]?.replace('T', ' ')} UTC`;
extractedNotice = extractedNotice.replace('{updated_timestamp}', formattedDate);
console.log('ProposalPolice™ editing issue comment...', payload.comment.id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ function isCommentCreatedEvent(payload: IssueCommentEvent): payload is IssueComm

// Main function to process the workflow event
async function run() {
// get date early, as soon as the workflow starts running
const date = new Date();
// Verify this is running for an expected webhook event
if (context.eventName !== CONST.EVENTS.ISSUE_COMMENT) {
throw new Error('ProposalPolice™ only supports the issue_comment webhook event');
Expand Down Expand Up @@ -87,8 +89,7 @@ async function run() {
// extract the text after [EDIT_COMMENT] from assistantResponse since this is a
// bot related action keyword
let extractedNotice = assistantResponse.split('[EDIT_COMMENT] ')?.[1]?.replace('"', '');
// format the github's updated_at like: 2024-01-24 13:15:24 UTC not 2024-01-28 18:18:28.000 UTC
const date = new Date(payload.comment?.updated_at ?? '');
// format the date like: 2024-01-24 13:15:24 UTC not 2024-01-28 18:18:28.000 UTC
const formattedDate = `${date.toISOString()?.split('.')?.[0]?.replace('T', ' ')} UTC`;
extractedNotice = extractedNotice.replace('{updated_timestamp}', formattedDate);
console.log('ProposalPolice™ editing issue comment...', payload.comment.id);
Expand Down
Loading