Skip to content

Commit 8bfe430

Browse files
authored
Update reminder.js
1 parent 42a7f14 commit 8bfe430

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

.github/scripts/reminder.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
const PAT_TOKEN = process.env.PAT_TOKEN;
22
const [REPO_OWNER, REPO_NAME] = process.env.GITHUB_REPOSITORY.split("/");
3-
const today = new Date().toISOString().split("T")[0];
43

54
async function getIssues() {
65
const query =
@@ -66,8 +65,8 @@ async function getIssues() {
6665
id: item.id,
6766
title: item.content.title,
6867
number: item.content.number,
69-
start: start.date,
70-
end: end.date,
68+
start: start?.date,
69+
end: end?.date,
7170
});
7271
});
7372

@@ -86,8 +85,10 @@ async function addComment(issueNumber, comment) {
8685
});
8786
}
8887

89-
function isDateBetween(date, start, end) {
90-
const currentDate = new Date(date);
88+
function isTodayBetween(start, end) {
89+
if (!start || !end) return false;
90+
91+
const currentDate = new Date().toISOString().split("T")[0];
9192
const startDate = new Date(start);
9293
const endDate = new Date(end);
9394

@@ -103,7 +104,7 @@ async function reminder() {
103104
}
104105

105106
for (const issue of issues) {
106-
if (!isDateBetween(today, issue.start, issue.end)) {
107+
if (!isTodayBetween(issue.start, issue.end)) {
107108
console.log(`No comments for issue #${issue.number}: ${issue.title}`);
108109
continue;
109110
}

0 commit comments

Comments
 (0)