You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
echo "Processing comment by $COMMENT_USER on issue #$ISSUE_NUMBER"
26
28
27
29
# Check if commenter is issue creator
28
30
if [ "$COMMENT_USER" = "$ISSUE_CREATOR" ]; then
@@ -31,19 +33,19 @@ jobs:
31
33
fi
32
34
33
35
# Check if commenter is organization member
34
-
if gh api orgs/$ORG_NAME/members/$COMMENT_USER > /dev/null 2>&1; then
36
+
if gh api "orgs/$ORG_NAME/members/$COMMENT_USER" > /dev/null 2>&1; then
35
37
echo "✅ Allowing comment from org member: $COMMENT_USER"
36
38
exit 0
37
39
fi
38
40
39
-
echo "🚫 Restricting comment from: $COMMENT_USER"
41
+
echo "🚫 Restricting comment from unauthorized user: $COMMENT_USER"
40
42
41
-
# Delete comment
42
-
gh api -X DELETE /repos/${{ github.repository }}/issues/comments/$COMMENT_ID
43
+
# Delete the unauthorized comment
44
+
gh api -X DELETE "/repos/$REPO/issues/comments/$COMMENT_ID"
45
+
echo "✅ Deleted comment from $COMMENT_USER"
43
46
44
-
# Lock issue
45
-
gh api -X PUT /repos/${{ github.repository }}/issues/$ISSUE_NUMBER/lock
47
+
# Add warning comment (this will be allowed since it's from the workflow)
48
+
gh api -X POST "/repos/$REPO/issues/$ISSUE_NUMBER/comments" \
49
+
-f body="⚠️ **Comment Removed**\n\n@$COMMENT_USER, only @$ORG_NAME organization members and the issue creator (@$ISSUE_CREATOR) can comment on this issue.\n\nYour comment has been removed but the discussion remains open for authorized participants."
46
50
47
-
# Add warning
48
-
gh api -X POST /repos/${{ github.repository }}/issues/$ISSUE_NUMBER/comments \
49
-
-f body="⚠️ **Comment Restricted**\n\nOnly @$ORG_NAME organization members and the issue creator (@$ISSUE_CREATOR) can comment on this issue."
0 commit comments