-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
1,459 additions
and
11 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
name: Send Plagiarism Result On CI Complete | ||
|
||
permissions: | ||
actions: read | ||
contents: read | ||
|
||
on: | ||
workflow_run: | ||
workflows: ["Plagiarism Checker"] | ||
types: | ||
- completed | ||
|
||
jobs: | ||
on_pr_finish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Download Plagiarism Report Artifact | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: plagiarism-report | ||
|
||
- name: Post Markdown as Comment | ||
uses: actions/github-script@v7 | ||
env: | ||
WORKFLOW_RUN_ID: ${{ github.event.workflow_run.id }} | ||
with: | ||
github-token: ${{secrets.GITHUB_TOKEN}} | ||
script: | | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
console.log("Reading the Markdown report from the artifact..."); | ||
const markdownContent = fs.readFileSync(path.join(process.env.GITHUB_WORKSPACE, 'plagiarism_report.md'), 'utf8'); | ||
console.log("Fetching associated workflow run..."); | ||
const runId = process.env.WORKFLOW_RUN_ID; | ||
console.log(`Looking for workflow run with ID: ${runId}`); | ||
const runs = await github.actions.listWorkflowRuns({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
workflow_id: 'check_plagiarism', | ||
}); | ||
console.log(`Workflow runs fetched: ${runs.data.total_count}`); | ||
runs.data.workflow_runs.forEach(run => { | ||
console.log(`Run ID: ${run.id}, Name: ${run.name}, Event: ${run.event}, Status: ${run.status}`); | ||
}); | ||
const associatedRun = runs.data.workflow_runs.find(run => run.id == runId); | ||
if (!associatedRun) { | ||
console.log("No associated workflow run found."); | ||
return; | ||
} | ||
console.log(`Operating on workflow: ${associatedRun.name}, ID: ${associatedRun.id}`); | ||
if (!associatedRun.pull_requests || associatedRun.pull_requests.length == 0) { | ||
console.log("No associated pull request found for this workflow run."); | ||
return; | ||
} | ||
const prNumber = associatedRun.pull_requests[0].number; | ||
console.log(`Found associated pull request: #${prNumber}`); | ||
console.log("Posting the Markdown content as a comment..."); | ||
await github.issues.createComment({ | ||
issue_number: prNumber, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: markdownContent | ||
}); | ||
console.log("Comment posted successfully."); |
Oops, something went wrong.