Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
DevIos01 authored Dec 23, 2023
2 parents a4d70c8 + 0bcd4fc commit c934416
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/check_plagiarism.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ jobs:
name: compare50-results
path: saved_dir/

- name: Save PR number to file
run: echo ${{ github.event.pull_request.number }} > pr_number.txt

- name: Upload PR Number as Artifact
uses: actions/upload-artifact@v4
with:
name: pr-number
path: pr_number.txt

- name: Upload Plagiarism Report as Artifact
if: always()
uses: actions/upload-artifact@v4
Expand Down
34 changes: 31 additions & 3 deletions .github/workflows/workflow_run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,36 @@ jobs:
console.log(`Artifact name: ${artifact.name}, ID: ${artifact.id}, Size: ${artifact.size_in_bytes} bytes`);
}
- name: Download PR Number Artifact
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const runId = ${{ github.event.workflow_run.id }};
const artifactName = 'pr-number';
console.log(`Downloading artifact ${artifactName} from workflow run ID: ${runId}`);
const artifactData = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: (await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: runId
})).data.artifacts.find(a => a.name === artifactName).id,
archive_format: 'zip',
});
const fs = require('fs');
const path = require('path');
const artifactPath = path.join(process.env.GITHUB_WORKSPACE, `${artifactName}.zip`);
fs.writeFileSync(artifactPath, Buffer.from(artifactData.data));
console.log(`Artifact ${artifactName} downloaded to ${artifactPath}`);
require('child_process').execSync(`unzip -o ${artifactPath} -d ${process.env.GITHUB_WORKSPACE}`);
const prNumber = fs.readFileSync(path.join(process.env.GITHUB_WORKSPACE, 'pr_number.txt'), 'utf8').trim();
console.log(`PR Number: ${prNumber}`);
- name: Download Plagiarism Report Artifact from Another Workflow Run
uses: actions/github-script@v7
with:
Expand Down Expand Up @@ -64,12 +94,11 @@ jobs:
archive_format: 'zip',
});
const fs = require('fs');
const path = require('path');
const artifactPath = path.join(process.env.GITHUB_WORKSPACE, `${artifactName}.zip`);
fs.writeFileSync(artifactPath, Buffer.from(artifactData.data));
console.log(`Artifact ${artifactName} downloaded to ${artifactPath}`);
require('child_process').execSync(`unzip -o ${artifactPath} -d ${process.env.GITHUB_WORKSPACE}`);
- name: List Contents of Zip File
run: unzip -l plagiarism-report.zip
Expand All @@ -93,7 +122,6 @@ jobs:
const markdownContent = fs.readFileSync(markdownPath, 'utf8');
console.log("Fetching associated pull request...");
const prNumber = ${{ github.event.workflow_run.pull_requests[0].number }};
console.log(`Found associated pull request: #${prNumber}`);
console.log("Posting the Markdown content as a comment...");
Expand Down

0 comments on commit c934416

Please sign in to comment.