copilot.yml 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. name: AI Code Reviewer
  2. on:
  3. workflow_run:
  4. workflows: ["Unittest"]
  5. types:
  6. - completed
  7. jobs:
  8. review:
  9. runs-on: ubuntu-latest
  10. permissions:
  11. contents: read
  12. pull-requests: write
  13. steps:
  14. - name: Checkout Repo
  15. uses: actions/checkout@v3
  16. - name: 'Download artifact'
  17. uses: actions/github-script@v6
  18. with:
  19. script: |
  20. let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
  21. owner: context.repo.owner,
  22. repo: context.repo.repo,
  23. run_id: context.payload.workflow_run.id,
  24. });
  25. let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
  26. return artifact.name == "pr_number"
  27. })[0];
  28. let download = await github.rest.actions.downloadArtifact({
  29. owner: context.repo.owner,
  30. repo: context.repo.repo,
  31. artifact_id: matchArtifact.id,
  32. archive_format: 'zip',
  33. });
  34. let fs = require('fs');
  35. fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/pr_number.zip`, Buffer.from(download.data));
  36. - name: 'Unzip artifact'
  37. run: unzip pr_number.zip
  38. - name: Setup Python
  39. uses: actions/setup-python@v4
  40. with:
  41. python-version: "3.x"
  42. cache: 'pip'
  43. - name: Install Requirements
  44. run: |
  45. pip install -r requirements.txt
  46. pip install PyGithub
  47. - name: AI Code Review
  48. env:
  49. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  50. GITHUB_REPOSITORY: ${{ github.repository }}
  51. run: python -m etc.tool.copilot