Skip to content

Commit

Permalink
Merge pull request #2 from kol3x/plagiarism-check-test-1
Browse files Browse the repository at this point in the history
Create test.yml
  • Loading branch information
kol3x authored Jun 10, 2024
2 parents d9dc799 + 69ac244 commit 1b10782
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
on:
issue_comment:
types: [created]

permissions:
contents: read
issues: read
pull-requests: write

jobs:
permission-check-job:
runs-on: ubuntu-latest
if: |
github.event.issue.pull_request &&
contains(github.event.comment.body, '/plagiarismcheck')
outputs:
permission: ${{ steps.permissions-check.outputs.defined }}
steps:
- name: Check for Secret availability
id: permissions-check
shell: bash
run: |
echo "defined=${{ contains(fromJSON(secrets.WIKI_REVIEWERS), github.actor) }}" >> $GITHUB_OUTPUT;
plagiarism-check:
runs-on: ubuntu-latest
name: "Checks a new article from a PR for plagiarism"
needs: [permission-check-job]
if: needs.permission-check-job.outputs.permission == 'true'

steps:
- name: Check out repository
uses: actions/checkout@v3

- name: Fetch Pull Request files
id: pr-files
run: |
pr_number=${{ github.event.issue.number }}
gh pr diff $pr_number --name-only > pr_files.txt
- name: Check for plagiarism
id: plagiarism-check
run: |
results=""
while IFS= read -r file; do
if [[ $file == *.md ]]; then
content=$(cat $file)
result=$(curl -s -X POST "https://<your-cloudflare-worker-url>" \
-H "Content-Type: application/json" \
-d "{\"text\": \"${content}\"}")
results="$file: $result"
break
fi
done < pr_files.txt
if [[ -z "$results" ]]; then
results="No markdown files found in the PR."
fi
echo "results=$results" >> $GITHUB_ENV
- name: Post result as a comment
run: |
gh pr comment ${{ github.event.issue.number }} --body "${{ env.results }}"

0 comments on commit 1b10782

Please sign in to comment.