diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml deleted file mode 100644 index 4b14a5e3..00000000 --- a/.github/workflows/deploy.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Build and Deploy to GitHub Pages - -on: - push: - branches: - - main - -permissions: - contents: read - pages: write - id-token: write - -jobs: - deploy: - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - runs-on: ubuntu-latest - - steps: - - name: Checkout Code - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v 4.2.2 - - - name: Generate contributors list - run: bash scripts/generate-cards.sh - - - name: Setup Pages - uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b #v5.0.0 - - name: Upload artifact - uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa #v3.0.1 - with: - path: "." - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e #v4.0.5 diff --git a/.github/workflows/toxicity-check.yml b/.github/workflows/toxicity-check.yml new file mode 100644 index 00000000..49e70fef --- /dev/null +++ b/.github/workflows/toxicity-check.yml @@ -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 diff --git a/contributors/harlanenciso112.html b/contributors/harlanenciso112.html new file mode 100644 index 00000000..fc3b8099 --- /dev/null +++ b/contributors/harlanenciso112.html @@ -0,0 +1,43 @@ +
+

Harlanenciso112

+

I'm Software Developer with experience languages with Python and Java.

+

Programming languages I use

+
+
+ Python +
+
+ Java +
+
+ +

Tools I use

+
+ + +
+
+ diff --git a/scripts/check_toxicity.py b/scripts/check_toxicity.py new file mode 100644 index 00000000..e32f5c9d --- /dev/null +++ b/scripts/check_toxicity.py @@ -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() diff --git a/scripts/contributors.js b/scripts/contributors.js index a090a27a..4a9b7544 100644 --- a/scripts/contributors.js +++ b/scripts/contributors.js @@ -1,4 +1,5 @@ const contributorFiles = [ + "harlanenciso112.html", "roshanjossey.html", - "gokultp.html", + "gokultp.html" ];