From 60fdb7ec2bd546040e0864e57bfbc0a4b2c4bdb8 Mon Sep 17 00:00:00 2001 From: Andy Feller Date: Fri, 1 Aug 2025 16:50:55 -0400 Subject: [PATCH 1/3] Update spam detection to comment on and close issue Fixes #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. --- .../scripts/spam-detection/process-issue.sh | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/.github/workflows/scripts/spam-detection/process-issue.sh b/.github/workflows/scripts/spam-detection/process-issue.sh index f65cb47e8..d9aff160f 100755 --- a/.github/workflows/scripts/spam-detection/process-issue.sh +++ b/.github/workflows/scripts/spam-detection/process-issue.sh @@ -9,16 +9,17 @@ set -euo pipefail +# Determine absolute path to script directory based on where it is called from. +# This allows the script to be run from any directory. +SPAM_DIR="$(dirname "$(realpath "$0")")" + _issue_url="$1" if [[ -z "$_issue_url" ]]; then echo "error: issue URL is empty" >&2 exit 1 fi -_suspected_spam_label="suspected-spam" -_check_issue_script=".github/workflows/scripts/spam-detection/check-issue.sh" - -_result="$($_check_issue_script "$_issue_url")" +_result="$("$SPAM_DIR/check-issue.sh" "$_issue_url")" if [[ "$_result" == "PASS" ]]; then echo "detected as not-spam: $_issue_url" @@ -27,6 +28,17 @@ fi echo "detected as spam: $_issue_url" -gh issue edit --add-label "$_suspected_spam_label" "$_issue_url" +cat << EOF | gh issue comment "$_issue_url" --body-file - +Thank you for taking the time to create this issue. + +We've automatically reviewed this issue and suspect it as potentially inauthentic or spam-like content. As a result, we're closing this issue. + +**If this was closed by mistake**, please don't hesitate to reach out to us by commenting on this issue with additional context. + +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. +EOF + +gh issue edit --add-label "suspected-spam" --add-label "invalid" "$_issue_url" +gh issue close "$_issue_url" echo "issue labelled as suspected spam" From 1e69d8a1a0676b4dbf9b2aba67fed7a53054cd0b Mon Sep 17 00:00:00 2001 From: Andy Feller Date: Mon, 4 Aug 2025 08:30:04 -0400 Subject: [PATCH 2/3] Update .github/workflows/scripts/spam-detection/process-issue.sh Co-authored-by: Babak K. Shandiz --- .github/workflows/scripts/spam-detection/process-issue.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/scripts/spam-detection/process-issue.sh b/.github/workflows/scripts/spam-detection/process-issue.sh index d9aff160f..10e5a528d 100755 --- a/.github/workflows/scripts/spam-detection/process-issue.sh +++ b/.github/workflows/scripts/spam-detection/process-issue.sh @@ -39,6 +39,6 @@ We appreciate your understanding and apologize if this action was taken in error EOF gh issue edit --add-label "suspected-spam" --add-label "invalid" "$_issue_url" -gh issue close "$_issue_url" +gh issue close --reason 'not planned' "$_issue_url" echo "issue labelled as suspected spam" From ccc1b4f8c7d8596fcb061d69322515e643cadb08 Mon Sep 17 00:00:00 2001 From: Andy Feller Date: Mon, 4 Aug 2025 08:30:16 -0400 Subject: [PATCH 3/3] Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/scripts/spam-detection/process-issue.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/scripts/spam-detection/process-issue.sh b/.github/workflows/scripts/spam-detection/process-issue.sh index 10e5a528d..ed8254356 100755 --- a/.github/workflows/scripts/spam-detection/process-issue.sh +++ b/.github/workflows/scripts/spam-detection/process-issue.sh @@ -41,4 +41,4 @@ EOF gh issue edit --add-label "suspected-spam" --add-label "invalid" "$_issue_url" gh issue close --reason 'not planned' "$_issue_url" -echo "issue labelled as suspected spam" +echo "issue processed as suspected spam: commented, closed, and labeled"