Implemented Automate Plagiarism / Copy Detection #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Plagiarism Checker | |
on: | |
pull_request: | |
paths: | |
- "**.js" | |
jobs: | |
plagiarism-check: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Get list of changed files | |
id: changed-files | |
run: | | |
base_sha="${{ github.event.pull_request.base.sha }}" | |
head_sha="${{ github.event.pull_request.head.sha }}" | |
js_files=$(git diff --name-only --diff-filter=AM $base_sha..$head_sha | grep '\.js$' | xargs) | |
echo "JavaScript files:" | |
echo "$js_files" | |
echo "FILES=$js_files" >> $GITHUB_ENV | |
- name: Run Plagiarism Detection Script | |
id: plagiarism-detection | |
run: node .github/scripts/plagiarismCheck.js $FILES games | |
env: | |
FILES: ${{ env.FILES }} | |
- name: Post Comment | |
if: always() | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
const fs = require('fs'); | |
const comment = fs.readFileSync('plagiarism-results.txt', 'utf8'); | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: comment | |
}); | |
- name: Fail if Plagiarism Detected | |
if: steps.plagiarism-detection.outcome == 'failure' | |
run: exit 1 |