Skip to content

Commit 77d9fee

Browse files
feat: readme updated (shubhaamgupta11#17)
* feat: enhanced readme and package json content * feat: version bumup
1 parent a3bea9f commit 77d9fee

File tree

9 files changed

+132
-83
lines changed

9 files changed

+132
-83
lines changed

.github/workflows/example.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
task: "monitor-issues"
2222
git_secret: ${{ secrets.GIT_SECRET }}
2323
notifier: "discord"
24-
fetch_data_interval: 24
25-
discord_webhook_url: "https://discord.com/api/webhooks/1332703260401729689/5RWQZ3PticjEsiOh3BlxxWHJj_t2ucxxqAfIDj3ELZeZ06JXSoqW2F4fxjhvvYc6hNkP"
24+
fetch_data_interval: 2 # in hours
25+
discord_webhook_url: ${{ secrets.DISCORD_WEBHOOK_URL }}
2626
repo_owner: "facebook"
2727
repo_name: "react-native"

README.md

Lines changed: 92 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,27 @@
1-
# Monitor Issues and PRs GitHub Action
1+
# GitHub Action for Tracking Issues & Pull Requests
22

3-
## Overview
4-
A GitHub Action to monitor new issues and pull requests in a specified repository and send notifications to Slack or Discord. This action allows you to track activity in your repositories and get alerted when new issues or PRs are created.
3+
Managing activity in open-source repositories can be challenging. With a constant influx of **issues** and **pull requests**, it's easy to lose track of what needs attention—especially when working with large teams or active projects. Missed notifications or delayed responses can lead to bottlenecks, reduced contributor satisfaction, and slower project progress.
54

6-
## Features
5+
## Repo Activity Monitor
76

8-
- Monitor issues and PRs in a GitHub repository.
9-
- Support for multiple notification methods.
10-
- Easy integration with GitHub workflows.
7+
This [GitHub Action](https://github.com/marketplace/actions/repo-monitor) empowers open-source maintainers by:
118

12-
## Inputs
9+
- Tracking new issues and pull requests in real time.
10+
- Sending notifications to your preferred communication platforms like **Slack** or **Discord**
1311

14-
| Input | Description | Required | Default |
15-
| ----- | ----------- | -------- | ------- |
16-
| task | The task to run (monitor-issues or monitor-prs). | Yes | None |
17-
| git_secret | GitHub token for authentication. | Yes | None |
18-
| repo_owner | The owner of the GitHub repository (`facebook`). | Yes | None |
19-
| repo_name | The name of the GitHub repository (`react-native`). | Yes | None |
20-
| fetch_data_interval | The time interval to fetch data for (e.g., 1 hour, 24 hours). This should align with the cron schedule. | Yes | None |
21-
| notifier | Notification method (**slack** or **discord**). | Yes | None |
22-
| slack_bot_token | Slack bot token to send notifications (required if notifier=`slack`). | No | None |
23-
| slack_channel | The Slack channel id to send notifications to (required if notifier=`slack`). | No | None |
24-
| slack_id_type | Type of Slack ID (user or group, required if notifier=`slack`). This is needed to ping someone directly. | No | None |
25-
| slack_id | user id or group id as per `slack_id_type` (required if notifier=`slack`). | No | None |
26-
| discord_webhook_url | Discord webhook URL to send notifications (required if notifier=`discord`). | No | None |
12+
With **Repo ActivityMonitor**, you can stay on top of your repositories' activities, streamline communication, and ensure no critical issues or pull requests fall through the cracks.
2713

28-
## Example Usage
14+
## Usage
15+
16+
### Monitoring Issues with Slack
2917

3018
```yml
3119
name: Monitor GitHub Repo
3220

3321
on:
3422
schedule:
3523
- cron: "0 * * * *" # Runs every hour
36-
workflow_dispatch:
24+
workflow_dispatch: # Optional
3725

3826
jobs:
3927
run-notifier:
@@ -43,46 +31,101 @@ jobs:
4331
uses: actions/setup-node@v3
4432
with:
4533
node-version: '16'
46-
- name: Run action
47-
uses: ./ # Path to your action
34+
- name: Monitor New Issues
35+
uses: shubhaamgupta11/[email protected]
4836
with:
4937
task: "monitor-issues"
5038
git_secret: "${{ secrets.GITHUB_TOKEN }}"
51-
notifier: "slack" # Or "discord"
52-
fetch_data_interval: 24 # Hours (must align with your cron schedule)
39+
notifier: "slack"
40+
fetch_data_interval: 1 # Hours (must align with your cron schedule)
5341
slack_bot_token: "${{ secrets.SLACK_BOT_TOKEN }}"
54-
slack_channel: "#your-channel"
55-
repo_owner: "facebook"
56-
repo_name: "react-native"
42+
slack_channel: "<channel-id>"
43+
slack_id_type: "<user/group>"
44+
slack_id: "<user-id/group-id>"
45+
repo_owner: "<owner>"
46+
repo_name: "<repo>"
47+
```
48+
49+
### Monitoring PRs with Discord
50+
51+
```yml
52+
name: Monitor GitHub Repo
53+
54+
on:
55+
schedule:
56+
- cron: "0 * * * *" # Runs every hour
57+
workflow_dispatch: # Optional to trigger manually
58+
59+
jobs:
60+
run-notifier:
61+
runs-on: ubuntu-latest
62+
steps:
63+
- name: Set up Node.js
64+
uses: actions/setup-node@v3
65+
with:
66+
node-version: '16'
67+
- name: Monitor New PRs
68+
uses: shubhaamgupta11/[email protected]
69+
with:
70+
task: "monitor-prs"
71+
git_secret: "${{ secrets.GITHUB_TOKEN }}"
72+
notifier: "discord"
73+
fetch_data_interval: 1 # Hours (must align with your cron schedule)
74+
discord_webhook_url: "${{ secrets.DISCORD_WEBHOOK_URL }}"
75+
repo_owner: "<owner>"
76+
repo_name: "<repo>"
5777
```
5878
59-
## How It Works
79+
> **Note:** You can configure any notifier (slack, discord, or others) for any task (monitor-issues, monitor-prs, etc.).
80+
81+
## 🔧 Inputs
82+
83+
| Input | Description | Required | Default |
84+
| ----- | ----------- | -------- | ------- |
85+
| task | The task to run (monitor-issues or monitor-prs). | Yes | None |
86+
| git_secret | GitHub token for authentication. | Yes | None |
87+
| repo_owner | The owner of the GitHub repository (`facebook`). | Yes | None |
88+
| repo_name | The name of the GitHub repository (`react-native`). | Yes | None |
89+
| fetch_data_interval | The time interval to fetch data for (e.g., 1 hour, 24 hours). This should align with the cron schedule. | Yes | None |
90+
| notifier | Notification method (**slack** or **discord**). | Yes | None |
91+
| slack_bot_token | Slack bot token to send notifications (required if notifier=`slack`). | No | None |
92+
| slack_channel | The Slack channel id to send notifications to (required if notifier=`slack`). | No | None |
93+
| slack_id_type | Type of Slack ID (user or group, required if notifier=`slack`). This is needed to ping someone directly. | No | None |
94+
| slack_id | user id or group id as per `slack_id_type` (required if notifier=`slack`). | No | None |
95+
| discord_webhook_url | Discord webhook URL to send notifications (required if notifier=`discord`). | No | None |
96+
97+
## 📖 How It Works
6098
- The action listens for new issues or PRs in the specified GitHub repository.
6199
- Depending on the `task` input, it will either monitor new issues (`monitor-issues`) or pull requests (`monitor-prs`).
62100
- Once a new issue or PR is detected, it sends a notification via Slack or Discord based on the `notifier` input.
63101
- The action checks for issues or PRs within the time period defined by `fetch_data_interval`, which should align with the cron schedule. For example, if the cron schedule is set to run every hour `(0 * * * *)`, set `fetch_data_interval` to 1 hour.
64102

65-
## Setting up Slack
66-
If you choose Slack as the notification method, you will need to create a Slack app and retrieve the **Slack Bot Token** and **Channel**:
103+
## 🔧 Setting Up
104+
105+
### Slack
106+
107+
- Create a Slack App.
108+
- Generate a Slack Bot Token.
109+
- Retrieve the Channel ID and User/Group IDs.
110+
- Add these secrets to your GitHub repository:
111+
- `SLACK_BOT_TOKEN`
112+
- `SLACK_CHANNEL`
113+
- `SLACK_ID_TYPE`
114+
- `SLACK_ID`
67115

68-
- Create a Slack app.
69-
- Generate a **Slack Bot Token**.
70-
- Get the **Channel I**D.
71-
- Get the **Slack User ID** or **Group ID**.
72-
- Add these tokens/IDs to the GitHub secrets (`SLACK_BOT_TOKEN`, `SLACK_CHANNEL`, `SLACK_ID_TYPE`, and `SLACK_ID`).
116+
### Discord
73117

74-
`slack_id_type` Explanation
75-
- `user`: Use this if you want to send a notification to an individual user.
76-
- `group`: Use this if you want to send a notification to a group of users (e.g., a Slack channel or a group).
118+
- Create a Discord Webhook.
119+
- Copy the Webhook URL.
120+
- Add the Webhook URL to your GitHub repository secrets as `DISCORD_WEBHOOK_URL`.
77121

78-
## Setting up Discord
79-
If you choose Discord as the notification method, you will need a Discord Webhook URL:
122+
## 🔮 Roadmap
80123

81-
- Create a **Discord Webhook**.
82-
- Copy the Webhook URL and add it to the GitHub secrets (`DISCORD_WEBHOOK_URL`).
124+
- [ ] **Generalize Notification Channels**: Allow adding multiple notification methods (e.g. Webhooks).
125+
- [ ] **Support Custom Filters**: Enable users to apply filters like labels, authors, or milestones to issues and PRs.
126+
- [ ] **Handle API Rate Limiting**: Add rate limiting or retry logic for handling GitHub API rate limits.
127+
- [ ] **Track inactivity** on issues and notify users after a specific TAT (Turnaround Time).
83128

84-
## Roadmap
85-
- [ ] Generalize Notification Channels: Allow adding multiple notification methods (e.g. Webhooks).
86-
- [ ] Support Custom Filters: Enable users to apply filters like labels, authors, or milestones to issues and PRs.
87-
- [ ] Handle API Rate Limiting: Add rate limiting or retry logic for handling GitHub API rate limits.
129+
## 📜 License
88130

131+
This project is licensed under the [MIT License](https://github.com/shubhaamgupta11/repo-monitor/blob/main/LICENSE).

action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ name: Repo Monitor
22
description: A GitHub Action to monitor new issues and pull requests and send notifications to Slack.
33
author: Shubham Gupta <[email protected]>
44
branding:
5-
icon: zap
6-
color: blue
5+
icon: bell
6+
color: green
77

88
inputs:
99
task:

action/monitor-new-issue.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const sendDiscordNotification = require("./integrations/discord");
1313
*/
1414
const fetchNewIssues = async (gitToken, owner, repo, alertTime) => {
1515
const apiUrl = `https://api.github.com/repos/${owner}/${repo}/issues`;
16-
16+
console.log("🔍 Fetching new issues... ", apiUrl);
1717
const sinceDate = new Date(
1818
new Date().getTime() - alertTime * 60 * 60 * 1000
1919
).toISOString();
@@ -76,6 +76,11 @@ async function monitorIssues({
7676
}) {
7777
const issues = await fetchNewIssues(gitToken, owner, repo, alertTime);
7878

79+
if (issues.length === 0) {
80+
console.log("No new issues found.");
81+
return;
82+
}
83+
7984
if (notifier === "slack") {
8085
const {
8186
slackToken,
@@ -84,7 +89,7 @@ async function monitorIssues({
8489
slackID,
8590
} = slackConfig;
8691
console.log(
87-
"Sending notifications to Slack for issues:",
92+
"🔔 Sending notifications to Slack for issues:",
8893
issues.map((issue) => issue.title)
8994
);
9095
await sendSlackNotification(
@@ -100,7 +105,7 @@ async function monitorIssues({
100105
discordWebhookUrl,
101106
} = discordConfig;
102107
console.log(
103-
"Sending notifications to Discord for issues:",
108+
"🔔 Sending notifications to Discord for issues:",
104109
issues.map((issue) => issue.title)
105110
);
106111
await sendDiscordNotification(discordWebhookUrl, issues, repo);

action/monitor-new-pr.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,14 @@ const sendDiscordNotification = require("./integrations/discord");
1313
*/
1414
const fetchNewPRs = async (gitToken, owner, repo, alertTime) => {
1515
const apiUrl = `https://api.github.com/repos/${owner}/${repo}/pulls`;
16+
console.log("🔍 Fetching new PRs... ", apiUrl);
1617
const cutoffDate = new Date(
1718
Date.now() - alertTime * 60 * 60 * 1000
1819
).toISOString();
1920

2021
let newPRs = [];
2122
let page = 1;
2223

23-
console.log(
24-
`Fetching new PRs created in the last ${alertTime} days from ${apiUrl}`
25-
);
26-
2724
try {
2825
while (true) {
2926
console.log(`Fetching page ${page}...`);
@@ -81,10 +78,11 @@ async function monitorPRs({
8178
console.log("Starting PR monitor...");
8279

8380
const prs = await fetchNewPRs(gitToken, owner, repo, alertTime);
84-
console.log(
85-
`Found ${prs.length} new PRs:`,
86-
prs.map((pr) => pr.title)
87-
);
81+
82+
if (prs.length === 0) {
83+
console.log("No new PRs found.");
84+
return;
85+
}
8886

8987
if (notifier === "slack") {
9088
const {
@@ -94,7 +92,7 @@ async function monitorPRs({
9492
slackID,
9593
} = slackConfig;
9694
console.log(
97-
"Sending notifications to Slack for PRs:",
95+
"🔔 Sending notifications to Slack for PRs:",
9896
prs.map((pr) => pr.title)
9997
);
10098
await sendSlackNotification(
@@ -110,7 +108,7 @@ async function monitorPRs({
110108
discordWebhookUrl,
111109
} = discordConfig;
112110
console.log(
113-
"Sending notifications to Discord for PRs:",
111+
"🔔 Sending notifications to Discord for PRs:",
114112
prs.map((pr) => pr.title)
115113
);
116114
await sendDiscordNotification(discordWebhookUrl, prs, repo);

dist/index.js

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ const sendDiscordNotification = __nccwpck_require__(9220);
146146
*/
147147
const fetchNewIssues = async (gitToken, owner, repo, alertTime) => {
148148
const apiUrl = `https://api.github.com/repos/${owner}/${repo}/issues`;
149-
149+
console.log("🔍 Fetching new issues... ", apiUrl);
150150
const sinceDate = new Date(
151151
new Date().getTime() - alertTime * 60 * 60 * 1000
152152
).toISOString();
@@ -209,6 +209,11 @@ async function monitorIssues({
209209
}) {
210210
const issues = await fetchNewIssues(gitToken, owner, repo, alertTime);
211211

212+
if (issues.length === 0) {
213+
console.log("No new issues found.");
214+
return;
215+
}
216+
212217
if (notifier === "slack") {
213218
const {
214219
slackToken,
@@ -217,7 +222,7 @@ async function monitorIssues({
217222
slackID,
218223
} = slackConfig;
219224
console.log(
220-
"Sending notifications to Slack for issues:",
225+
"🔔 Sending notifications to Slack for issues:",
221226
issues.map((issue) => issue.title)
222227
);
223228
await sendSlackNotification(
@@ -233,7 +238,7 @@ async function monitorIssues({
233238
discordWebhookUrl,
234239
} = discordConfig;
235240
console.log(
236-
"Sending notifications to Discord for issues:",
241+
"🔔 Sending notifications to Discord for issues:",
237242
issues.map((issue) => issue.title)
238243
);
239244
await sendDiscordNotification(discordWebhookUrl, issues, repo);
@@ -264,17 +269,14 @@ const sendDiscordNotification = __nccwpck_require__(9220);
264269
*/
265270
const fetchNewPRs = async (gitToken, owner, repo, alertTime) => {
266271
const apiUrl = `https://api.github.com/repos/${owner}/${repo}/pulls`;
272+
console.log("🔍 Fetching new PRs... ", apiUrl);
267273
const cutoffDate = new Date(
268274
Date.now() - alertTime * 60 * 60 * 1000
269275
).toISOString();
270276

271277
let newPRs = [];
272278
let page = 1;
273279

274-
console.log(
275-
`Fetching new PRs created in the last ${alertTime} days from ${apiUrl}`
276-
);
277-
278280
try {
279281
while (true) {
280282
console.log(`Fetching page ${page}...`);
@@ -332,10 +334,11 @@ async function monitorPRs({
332334
console.log("Starting PR monitor...");
333335

334336
const prs = await fetchNewPRs(gitToken, owner, repo, alertTime);
335-
console.log(
336-
`Found ${prs.length} new PRs:`,
337-
prs.map((pr) => pr.title)
338-
);
337+
338+
if (prs.length === 0) {
339+
console.log("No new PRs found.");
340+
return;
341+
}
339342

340343
if (notifier === "slack") {
341344
const {
@@ -345,7 +348,7 @@ async function monitorPRs({
345348
slackID,
346349
} = slackConfig;
347350
console.log(
348-
"Sending notifications to Slack for PRs:",
351+
"🔔 Sending notifications to Slack for PRs:",
349352
prs.map((pr) => pr.title)
350353
);
351354
await sendSlackNotification(
@@ -361,7 +364,7 @@ async function monitorPRs({
361364
discordWebhookUrl,
362365
} = discordConfig;
363366
console.log(
364-
"Sending notifications to Discord for PRs:",
367+
"🔔 Sending notifications to Discord for PRs:",
365368
prs.map((pr) => pr.title)
366369
);
367370
await sendDiscordNotification(discordWebhookUrl, prs, repo);

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.

0 commit comments

Comments
 (0)