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

chore: add GitHub Action to manage "+1" comments #52866

Merged
merged 17 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/minus-one/index.mjs

Large diffs are not rendered by default.

14 changes: 11 additions & 3 deletions .github/actions/minus-one/src/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@ import { context } from '@actions/github'
import { info, setFailed } from '@actions/core'
import { graphql } from '@octokit/graphql'

const offTopicComments = ['+1', '👍', 'same issue', 'any updates']
function isUnhelpfulComment(text) {
// Borrowed from Refined GitHub:
balazsorban44 marked this conversation as resolved.
Show resolved Hide resolved
// https://github.com/refined-github/refined-github/blob/c864a20b57bb433aaf3952f88d83c9fc481ae6ff/source/helpers/is-low-quality-comment.ts#L2-L3
return (
text.replace(
/[\s,.!?👍👎👌🙏]+|[\u{1F3FB}-\u{1F3FF}]|[+-]\d+|⬆️|ditt?o|me|too|t?here|on|same|this|issues?|please|pl[sz]|any|updates?|bump|question|solution|following/giu,
''
) === ''
)
}

async function run() {
try {
Expand All @@ -14,8 +23,7 @@ async function run() {

const { node_id: subjectId, body } = comment

const bodyLower = body.toLowerCase()
if (offTopicComments.some((comment) => bodyLower === comment)) {
if (isUnhelpfulComment(body)) {
await graphql(
`
mutation minimize($subjectId: ID!) {
Expand Down