Skip to content

Commit 60fdb7e

Browse files
committed
Update spam detection to comment on and close issue
Fixes cli#11408 These changes enhance the GitHub CLI spam detection logic to automatically comment on and close suspected spam based on the past weeks of usage. Additionally, there were a few minor enhancements to the script, allowing it to be executed from anywhere rather than the root of the local repository.
1 parent 6888786 commit 60fdb7e

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

.github/workflows/scripts/spam-detection/process-issue.sh

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,17 @@
99

1010
set -euo pipefail
1111

12+
# Determine absolute path to script directory based on where it is called from.
13+
# This allows the script to be run from any directory.
14+
SPAM_DIR="$(dirname "$(realpath "$0")")"
15+
1216
_issue_url="$1"
1317
if [[ -z "$_issue_url" ]]; then
1418
echo "error: issue URL is empty" >&2
1519
exit 1
1620
fi
1721

18-
_suspected_spam_label="suspected-spam"
19-
_check_issue_script=".github/workflows/scripts/spam-detection/check-issue.sh"
20-
21-
_result="$($_check_issue_script "$_issue_url")"
22+
_result="$("$SPAM_DIR/check-issue.sh" "$_issue_url")"
2223

2324
if [[ "$_result" == "PASS" ]]; then
2425
echo "detected as not-spam: $_issue_url"
@@ -27,6 +28,17 @@ fi
2728

2829
echo "detected as spam: $_issue_url"
2930

30-
gh issue edit --add-label "$_suspected_spam_label" "$_issue_url"
31+
cat << EOF | gh issue comment "$_issue_url" --body-file -
32+
Thank you for taking the time to create this issue.
33+
34+
We've automatically reviewed this issue and suspect it as potentially inauthentic or spam-like content. As a result, we're closing this issue.
35+
36+
**If this was closed by mistake**, please don't hesitate to reach out to us by commenting on this issue with additional context.
37+
38+
We appreciate your understanding and apologize if this action was taken in error. Our automated systems help us manage the large volume of issues we receive, but we know they're not perfect.
39+
EOF
40+
41+
gh issue edit --add-label "suspected-spam" --add-label "invalid" "$_issue_url"
42+
gh issue close "$_issue_url"
3143

3244
echo "issue labelled as suspected spam"

0 commit comments

Comments
 (0)