review-pr.yml 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. name: Use OpenDevin to Review Pull Request
  2. on:
  3. pull_request:
  4. types: [synchronize, labeled]
  5. permissions:
  6. contents: write
  7. pull-requests: write
  8. jobs:
  9. dogfood:
  10. if: contains(github.event.pull_request.labels.*.name, 'review-this')
  11. runs-on: ubuntu-latest
  12. container:
  13. image: ghcr.io/opendevin/opendevin
  14. volumes:
  15. - /var/run/docker.sock:/var/run/docker.sock
  16. steps:
  17. - name: install git, github cli
  18. run: |
  19. apt-get install -y git gh
  20. git config --global --add safe.directory $PWD
  21. - name: Checkout Repository
  22. uses: actions/checkout@v4
  23. with:
  24. ref: ${{ github.event.pull_request.base.ref }} # check out the target branch
  25. - name: Download Diff
  26. run: |
  27. curl -O "${{ github.event.pull_request.diff_url }}" -L
  28. - name: Write Task File
  29. run: |
  30. echo "Your coworker wants to apply a pull request to this project. Read and review ${{ github.event.pull_request.number }}.diff file. Create a review-${{ github.event.pull_request.number }}.txt and write your concise comments and suggestions there." > task.txt
  31. echo "" >> task.txt
  32. echo "Title" >> task.txt
  33. echo "${{ github.event.pull_request.title }}" >> task.txt
  34. echo "" >> task.txt
  35. echo "Description" >> task.txt
  36. echo "${{ github.event.pull_request.body }}" >> task.txt
  37. echo "" >> task.txt
  38. echo "Diff file is: ${{ github.event.pull_request.number }}.diff" >> task.txt
  39. - name: Run OpenDevin
  40. env:
  41. LLM_API_KEY: ${{ secrets.OPENAI_API_KEY }}
  42. SANDBOX_TYPE: exec
  43. run: |
  44. WORKSPACE_MOUNT_PATH=$GITHUB_WORKSPACE python ./opendevin/main.py -i 50 -f task.txt -d $GITHUB_WORKSPACE
  45. rm task.txt
  46. - name: Check if review file is non-empty
  47. id: check_file
  48. run: |
  49. ls -la
  50. if [[ -s review-${{ github.event.pull_request.number }}.txt ]]; then
  51. echo "non_empty=true" >> $GITHUB_OUTPUT
  52. fi
  53. shell: bash
  54. - name: Create PR review if file is non-empty
  55. env:
  56. GH_TOKEN: ${{ github.token }}
  57. if: steps.check_file.outputs.non_empty == 'true'
  58. run: |
  59. gh pr review ${{ github.event.pull_request.number }} --comment --body-file "review-${{ github.event.pull_request.number }}.txt"