solve-issue.yml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. name: Use OpenDevin to Resolve GitHub Issue
  2. on:
  3. issues:
  4. types: [labeled]
  5. permissions:
  6. contents: write
  7. pull-requests: write
  8. issues: write
  9. jobs:
  10. dogfood:
  11. if: github.event.label.name == 'solve-this'
  12. runs-on: ubuntu-latest
  13. container:
  14. image: ghcr.io/opendevin/opendevin
  15. volumes:
  16. - /var/run/docker.sock:/var/run/docker.sock
  17. steps:
  18. - name: install git, github cli
  19. run: apt-get install -y git gh
  20. - name: Checkout Repository
  21. uses: actions/checkout@v4
  22. - name: Write Task File
  23. env:
  24. ISSUE_TITLE: ${{ github.event.issue.title }}
  25. ISSUE_BODY: ${{ github.event.issue.body }}
  26. run: |
  27. echo "TITLE:" > task.txt
  28. echo "${ISSUE_TITLE}" >> task.txt
  29. echo "" >> task.txt
  30. echo "BODY:" >> task.txt
  31. echo "${ISSUE_BODY}" >> task.txt
  32. - name: Set up environment
  33. run: |
  34. curl -sSL https://install.python-poetry.org | python3 -
  35. export PATH="/github/home/.local/bin:$PATH"
  36. poetry install --without evaluation
  37. poetry run playwright install --with-deps chromium
  38. - name: Run OpenDevin
  39. env:
  40. ISSUE_TITLE: ${{ github.event.issue.title }}
  41. ISSUE_BODY: ${{ github.event.issue.body }}
  42. LLM_API_KEY: ${{ secrets.OPENAI_API_KEY }}
  43. OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
  44. SANDBOX_BOX_TYPE: ssh
  45. run: |
  46. # Append path to launch poetry
  47. export PATH="/github/home/.local/bin:$PATH"
  48. # Append path to correctly import package, note: must set pwd at first
  49. export PYTHONPATH=$(pwd):$PYTHONPATH
  50. WORKSPACE_MOUNT_PATH=$GITHUB_WORKSPACE poetry run python ./opendevin/core/main.py -i 50 -f task.txt -d $GITHUB_WORKSPACE
  51. rm task.txt
  52. - name: Setup Git, Create Branch, and Commit Changes
  53. run: |
  54. # Setup Git configuration
  55. git config --global --add safe.directory $PWD
  56. git config --global user.name 'OpenDevin'
  57. git config --global user.email 'OpenDevin@users.noreply.github.com'
  58. # Create a unique branch name with a timestamp
  59. BRANCH_NAME="fix/${{ github.event.issue.number }}-$(date +%Y%m%d%H%M%S)"
  60. # Checkout new branch
  61. git checkout -b $BRANCH_NAME
  62. # Add all changes to staging, except task.txt
  63. git add --all -- ':!task.txt'
  64. # Commit the changes, if any
  65. git commit -m "OpenDevin: Resolve Issue #${{ github.event.issue.number }}"
  66. if [ $? -ne 0 ]; then
  67. echo "No changes to commit."
  68. exit 0
  69. fi
  70. # Push changes
  71. git push --set-upstream origin $BRANCH_NAME
  72. - name: Fetch Default Branch
  73. env:
  74. GH_TOKEN: ${{ github.token }}
  75. run: |
  76. # Fetch the default branch using gh cli
  77. DEFAULT_BRANCH=$(gh repo view --json defaultBranchRef --jq .defaultBranchRef.name)
  78. echo "Default branch is $DEFAULT_BRANCH"
  79. echo "DEFAULT_BRANCH=$DEFAULT_BRANCH" >> $GITHUB_ENV
  80. - name: Generate PR
  81. env:
  82. GH_TOKEN: ${{ github.token }}
  83. run: |
  84. # Create PR and capture URL
  85. PR_URL=$(gh pr create \
  86. --title "OpenDevin: Resolve Issue #2" \
  87. --body "This PR was generated by OpenDevin to resolve issue #2" \
  88. --repo "foragerr/OpenDevin" \
  89. --head "${{ github.head_ref }}" \
  90. --base "${{ env.DEFAULT_BRANCH }}" \
  91. | grep -o 'https://github.com/[^ ]*')
  92. # Extract PR number from URL
  93. PR_NUMBER=$(echo "$PR_URL" | grep -o '[0-9]\+$')
  94. # Set environment vars
  95. echo "PR_URL=$PR_URL" >> $GITHUB_ENV
  96. echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
  97. - name: Post Comment
  98. env:
  99. GH_TOKEN: ${{ github.token }}
  100. run: |
  101. gh issue comment ${{ github.event.issue.number }} \
  102. -b "OpenDevin raised [PR #${{ env.PR_NUMBER }}](${{ env.PR_URL }}) to resolve this issue."