Skip to content

Commit cf7c2b9

Browse files
authored
Merge pull request cli#11435 from cli/andyfeller/11408-close-suspected-spam-issues
Update spam detection to comment on and close issue
2 parents 24f502b + ccc1b4f commit cf7c2b9

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

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

Lines changed: 18 additions & 6 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 --reason 'not planned' "$_issue_url"
3143

32-
echo "issue labelled as suspected spam"
44+
echo "issue processed as suspected spam: commented, closed, and labeled"

0 commit comments

Comments
 (0)