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

Feature: Split PR & issues into separate events #272

Merged
merged 10 commits into from
May 2, 2023
Merged
Show file tree
Hide file tree
Changes from 9 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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ Events we support:
- ForkEvent - You forked a repo
- GollumEvent - Wiki was updated in a repo
- IssueCommentEvent - You commented on a issue
- IssuesEvent - You opened a issue
- IssuesEvent - You opened or closed an issue
- MemberEvent - You joined a org/repo as a member
- PullRequestEvent - You opened a pr.
- PullRequestEvent - You opened, merged or closed a pr.
- PullRequestReviewCommentEvent - You commented on a pr review
- PullRequestReviewEvent - You reviewed a pr
- ReleaseEvent - You released a new version
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

31 changes: 18 additions & 13 deletions docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,19 +161,24 @@ The setting can be used in two ways:
##### Supported Events
The following list of events is supported for the [`disabled_events`](#disabled_events) and [`whitelisted_events`](#whitelisted_events) setting.

| Type: | Disabled Actions: |
| ------------- | ------------------------------------------------- |
| `comments` | Commenting on Issues |
| `create_repo` | Creating a new Repository |
| `fork` | Forking a Repository |
| `issues` | Opening or closing Issues |
| `member` | Getting added as a Collaborator/Member |
| `pr` | Opening, closing or Merging a Pull request |
| `push` | All commits performed |
| `release` | Publishing a new Release |
| `review` | Approving or requesting Changes in a Pull request |
| `star` | Starring a Repository |
| `wiki` | Creating a new Wiki page |
| Type: | Disabled Actions: |
| -------------- | ------------------------------------------------- |
| `comments` | Commenting on Issues |
| `create_repo` | Creating a new Repository |
| `fork` | Forking a Repository |
| `issues` | All Issues actions |
| `issues_open` | Opening Issues |
| `issues_close` | Closing Issues |
| `member` | Getting added as a Collaborator/Member |
| `pr` | All Pull request actions |
| `pr_open` | Opening a Pull request |
| `pr_merge` | Merging a Pull request |
| `pr_close` | Closing a Pull request |
| `push` | All commits performed |
| `release` | Publishing a new Release |
| `review` | Approving or requesting Changes in a Pull request |
| `star` | Starring a Repository |
| `wiki` | Creating a new Wiki page |

#### `commit_name`
> **Default:** `readme-bot`
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "activity-readme",
"version": "2.4.1",
"version": "2.5.0",
"description": "Updates README with the recent GitHub activity of a user. This project is a fork of https://github.com/jamesgeorge007/github-activity-readme",
"main": "src/index.js",
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const defaultVals = {
text: "Last Updated: {DATE}",
format: "dddd, mmmm dS, yyyy, h:MM:ss TT",
},
ignored_repos:[],
ignored_repos: [],
comments: "💬 Commented on {ID} in {REPO}",
push: "⬆️ Pushed {AMOUNT} commit(s) to {REPO}",
issue_opened: "❗️ Opened issue {ID} in {REPO}",
Expand Down
7 changes: 6 additions & 1 deletion src/eventList.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
/**
* Copyright (c) 2021 The Readme-Workflows organisation and Contributors
* Copyright (c) 2023 The Readme-Workflows organisation and Contributors
*/
module.exports = [
"comments",
"push",
"create_repo",
"fork",
"issues",
"issues_open",
"issues_close",
"member",
"pr",
"pr_open",
"pr_merge",
"pr_close",
"release",
"review",
"star",
Expand Down
41 changes: 40 additions & 1 deletion src/functions/filterContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

const serializers = require("../serializers");
const { max_lines, ignored_repos } = require("../config");
const { max_lines, ignored_repos, disabled_events } = require("../config");
const { amountReplace } = require("./amountReplacer");

const filterContent = (eventData) => {
Expand All @@ -16,6 +16,45 @@ const filterContent = (eventData) => {
(event) => !ignored_repos.includes(event.repo.name)
);
}

if (disabled_events instanceof Array && disabled_events.length != 0) {
eventData = eventData.filter((event) => {
if (
disabled_events.includes("issues_open") &&
event.payload.action === "opened" &&
event.type === "IssuesEvent"
) {
return false;
} else if (
disabled_events.includes("issues_close") &&
event.payload.action === "closed" &&
event.type === "IssuesEvent"
) {
return false;
} else if (
disabled_events.includes("pr_open") &&
event.payload.action === "opened" &&
event.type === "PullRequestEvent"
) {
return false;
} else if (
disabled_events.includes("pr_merge") &&
event.payload.pull_request.merged &&
event.type === "PullRequestEvent"
) {
return false;
} else if (
disabled_events.includes("pr_close") &&
event.payload.action === "closed" &&
event.type === "PullRequestEvent"
) {
return false;
} else {
return true;
}
});
}

for (let i = 0; i < eventData.length; i++) {
let event_string = serializers[eventData[i].type](eventData[i]);

Expand Down