Skip to content

Commit d58266a

Browse files
feat: better log added for debugging (#1)
* feat: better log added * feat: readme update
1 parent 44bb20a commit d58266a

File tree

7 files changed

+33
-5
lines changed

7 files changed

+33
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
with:
3434
node-version: '20'
3535
- name: Monitor New Issues
36-
uses: react-native-community/[email protected].0
36+
uses: react-native-community/[email protected].1
3737
with:
3838
# required inputs
3939
task: "monitor-issues"

action/monitor-new-issue.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ const fetchNewIssues = async (gitToken, owner, repo, alertTime) => {
1818
new Date().getTime() - alertTime * 60 * 60 * 1000
1919
).toISOString();
2020

21+
console.log(`🕒 Script executed at: ${new Date().toLocaleString()}`);
22+
console.log(`🔍 Fetching new issues since: ${new Date(sinceDate).toLocaleString()}`);
2123
let newIssues = [];
2224
let page = 1;
2325

@@ -60,6 +62,11 @@ const fetchNewIssues = async (gitToken, owner, repo, alertTime) => {
6062
page++; // Move to the next page
6163
}
6264

65+
console.log(
66+
"Issues Found :",
67+
newIssues.map((issue) => `Title: ${issue.title}, Created At: ${new Date(issue.createdAt).toLocaleString()}`)
68+
);
69+
6370
return newIssues;
6471
} catch (error) {
6572
console.error("Error fetching issues:", error.response.data);

action/monitor-new-pr.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ const fetchNewPRs = async (gitToken, owner, repo, alertTime) => {
1818
Date.now() - alertTime * 60 * 60 * 1000
1919
).toISOString();
2020

21+
console.log(`🕒 Script executed at: ${new Date().toLocaleString()}`);
22+
console.log(`🔍 Fetching new prs since: ${new Date(cutoffDate).toLocaleString()}`);
23+
2124
let newPRs = [];
2225
let page = 1;
2326
let olderThanCutoff = false;
@@ -65,6 +68,10 @@ const fetchNewPRs = async (gitToken, owner, repo, alertTime) => {
6568
}
6669

6770
console.log(`Fetched ${newPRs.length} new PR(s)`);
71+
console.log(
72+
"New PRs Found :",
73+
newPRs.map((pr) => `Title: ${pr.title}, Created At: ${new Date(pr.createdAt).toLocaleString()}`)
74+
);
6875
return newPRs;
6976
} catch (error) {
7077
console.error("Error fetching PRs:", error.message);

dist/index.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ const fetchNewIssues = async (gitToken, owner, repo, alertTime) => {
154154
new Date().getTime() - alertTime * 60 * 60 * 1000
155155
).toISOString();
156156

157+
console.log(`🕒 Script executed at: ${new Date().toLocaleString()}`);
158+
console.log(`🔍 Fetching new issues since: ${new Date(sinceDate).toLocaleString()}`);
157159
let newIssues = [];
158160
let page = 1;
159161

@@ -196,6 +198,11 @@ const fetchNewIssues = async (gitToken, owner, repo, alertTime) => {
196198
page++; // Move to the next page
197199
}
198200

201+
console.log(
202+
"Issues Found :",
203+
newIssues.map((issue) => `Title: ${issue.title}, Created At: ${new Date(issue.createdAt).toLocaleString()}`)
204+
);
205+
199206
return newIssues;
200207
} catch (error) {
201208
console.error("Error fetching issues:", error.response.data);
@@ -294,6 +301,9 @@ const fetchNewPRs = async (gitToken, owner, repo, alertTime) => {
294301
Date.now() - alertTime * 60 * 60 * 1000
295302
).toISOString();
296303

304+
console.log(`🕒 Script executed at: ${new Date().toLocaleString()}`);
305+
console.log(`🔍 Fetching new prs since: ${new Date(cutoffDate).toLocaleString()}`);
306+
297307
let newPRs = [];
298308
let page = 1;
299309
let olderThanCutoff = false;
@@ -341,6 +351,10 @@ const fetchNewPRs = async (gitToken, owner, repo, alertTime) => {
341351
}
342352

343353
console.log(`Fetched ${newPRs.length} new PR(s)`);
354+
console.log(
355+
"New PRs Found :",
356+
newPRs.map((pr) => `Title: ${pr.title}, Created At: ${new Date(pr.createdAt).toLocaleString()}`)
357+
);
344358
return newPRs;
345359
} catch (error) {
346360
console.error("Error fetching PRs:", error.message);

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "repo-monitor",
3-
"version": "1.0.2",
3+
"version": "1.0.1",
44
"description": "A GitHub Action to monitor a repository for new issues and PRs and send notifications to different channels.",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)