Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 0 additions & 35 deletions .github/workflows/deploy.yml

This file was deleted.

55 changes: 55 additions & 0 deletions .github/workflows/toxicity-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Check for Toxic Content
#hi
on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
moderate-content:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: "3.x"

- name: Cache Hugging Face models
uses: actions/cache@v3
with:
path: ~/.cache/huggingface
key: huggingface-toxicity-model

- name: Install dependencies
run: pip install transformers torch beautifulsoup4 python-magic

- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v35
with:
files: "**/*"

- name: Run toxicity check
run: |
for file in ${{ steps.changed-files.outputs.all_modified_files }}; do
python scripts/check_toxicity.py "$file"
done

- name: Auto-approve PR if no offensive content is found
if: success()
uses: hmarr/auto-approve-action@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Comment on PR if offensive content is detected
if: failure()
run: echo "🚨 Offensive content detected. Please review your PR." | tee comment.txt

- name: Post comment on PR
if: failure()
uses: thollander/actions-comment-pull-request@v2
with:
message: file://comment.txt
43 changes: 43 additions & 0 deletions contributors/harlanenciso112.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<article>
<h3>Harlanenciso112</h3>
<p>I'm Software Developer with experience languages with Python and Java.</p>
<h4>Programming languages I use</h4>
<section class="container">
<div class="badge" style="background-color: #3874a4; color: white">
Python
</div>
<div class="badge" style="background-color: #f7991e; color: black;">
Java
</div>
</section>

<h4>Tools I use</h4>
<section class="container">
<img
class="icon"
src="https://cdn.jsdelivr.net/gh/devicons/devicon@latest/icons/python/python-original-wordmark.svg"
/>
<img
class="icon"

src="https://cdn.jsdelivr.net/gh/devicons/devicon@latest/icons/java/java-original-wordmark.svg"
/>
</section>
</article>
<style>
body {
font-family: sans-serif;
}
.container {
display: flex;
flex-wrap: wrap;
gap: 1rem;
}
.badge {
padding: 0.5rem;
border-radius: 0.25rem;
}
.icon {
width: 2rem;
}
</style>
80 changes: 80 additions & 0 deletions scripts/check_toxicity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import sys
import os
import magic
from bs4 import BeautifulSoup
from transformers import pipeline

# Load the toxicity detection model
classifier = pipeline("text-classification", model="unitary/toxic-bert")

# List of offensive words (modify as needed)
OFFENSIVE_WORDS = ["fuck", "shit", "bitch"]

def is_text_file(file_path):
"""Check if the file is a text-based file (not binary)"""
mime = magic.Magic(mime=True)
file_type = mime.from_file(file_path)
return file_type.startswith("text")

def check_text(text):
"""Analyze text using the toxicity classifier"""
result = classifier(text[:512]) # Limit to 512 tokens (model constraint)
label = result[0]["label"]
score = result[0]["score"]

return label == "toxic" and score > 0.7 # If toxic, return True

def check_file_content(file_path):
"""Read file and analyze its content for toxicity"""
if not is_text_file(file_path):
print(f"⚠️ Skipping binary file: {file_path}")
return False

with open(file_path, "r", encoding="utf-8", errors="ignore") as file:
content = file.read()

# If it's an HTML file, extract text
if file_path.endswith(".html"):
soup = BeautifulSoup(content, "html.parser")
content = soup.get_text()

return check_text(content)

def check_filename(file_name):
"""Check if the filename contains offensive words"""
lower_name = file_name.lower()
for word in OFFENSIVE_WORDS:
if word in lower_name:
print(f"❌ Offensive word detected in filename: {file_name}")
return True
return False

def main():
"""Check all modified files in the PR"""
offensive_found = False

# Get list of modified files from Git
modified_files = os.popen("git diff --name-only HEAD^ HEAD").read().split()

for file in modified_files:
if not os.path.exists(file):
continue # Skip deleted files

# Check filename for offensive words
if check_filename(file):
offensive_found = True

# Check file content for toxicity
if check_file_content(file):
print(f"❌ Offensive content detected in {file}")
offensive_found = True

# Block the PR if any offensive content was found
if offensive_found:
sys.exit(1)
else:
print("✅ No offensive content found.")
sys.exit(0)

if __name__ == "__main__":
main()
3 changes: 2 additions & 1 deletion scripts/contributors.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const contributorFiles = [
"harlanenciso112.html",
"roshanjossey.html",
"gokultp.html",
"gokultp.html"
];