dogfood.yml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. open-devin:
  11. if: github.event.label.name == 'dogfood-this'
  12. runs-on: ubuntu-latest
  13. environment: OpenAI
  14. steps:
  15. - name: Checkout Repository
  16. uses: actions/checkout@v4
  17. - name: Install poetry
  18. run: pipx install poetry
  19. - name: Set up Python
  20. uses: actions/setup-python@v5
  21. with:
  22. python-version: '3.12'
  23. cache: 'poetry'
  24. - name: Install Dependencies
  25. run: |
  26. make build
  27. - name: Write Task File
  28. env:
  29. ISSUE_TITLE: ${{ github.event.issue.title }}
  30. ISSUE_BODY: ${{ github.event.issue.body }}
  31. run: |
  32. echo "TITLE:" > task.txt
  33. echo "${ISSUE_TITLE}" >> task.txt
  34. echo "" >> task.txt
  35. echo "BODY:" >> task.txt
  36. echo "${ISSUE_BODY}" >> task.txt
  37. - name: Run OpenDevin
  38. env:
  39. ISSUE_TITLE: ${{ github.event.issue.title }}
  40. ISSUE_BODY: ${{ github.event.issue.body }}
  41. LLM_API_KEY: ${{ secrets.OPENAI_API_KEY }}
  42. run: |
  43. poetry run python ./opendevin/main.py -d "./" -i 50 -f task.txt
  44. - name: Setup Git, Create Branch, and Commit Changes
  45. run: |
  46. # Setup Git configuration
  47. git config --global user.name 'OpenDevin'
  48. git config --global user.email 'OpenDevin@users.noreply.github.com'
  49. # Create a unique branch name with a timestamp
  50. BRANCH_NAME="fix/${{ github.event.issue.number }}-$(date +%Y%m%d%H%M%S)"
  51. # Checkout new branch
  52. git checkout -b $BRANCH_NAME
  53. # Add all changes to staging, except task.txt
  54. git add --all -- ':!task.txt'
  55. # Commit the changes, if any
  56. git commit -m "OpenDevin: Resolve Issue #${{ github.event.issue.number }}"
  57. if [ $? -ne 0 ]; then
  58. echo "No changes to commit."
  59. exit 0
  60. fi
  61. # Push changes
  62. git push --set-upstream origin $BRANCH_NAME
  63. - name: Install GitHub CLI
  64. run: |
  65. sudo apt-get install gh
  66. - name: Fetch Default Branch
  67. env:
  68. GH_TOKEN: ${{ github.token }}
  69. run: |
  70. # Fetch the default branch using gh cli
  71. DEFAULT_BRANCH=$(gh repo view --json defaultBranchRef --jq .defaultBranchRef.name)
  72. echo "Default branch is $DEFAULT_BRANCH"
  73. echo "DEFAULT_BRANCH=$DEFAULT_BRANCH" >> $GITHUB_ENV
  74. - name: Generate PR
  75. env:
  76. GH_TOKEN: ${{ github.token }}
  77. run: |
  78. # Create PR and capture URL
  79. PR_URL=$(gh pr create \
  80. --title "OpenDevin: Resolve Issue #2" \
  81. --body "This PR was generated by OpenDevin to resolve issue #2" \
  82. --repo "foragerr/OpenDevin" \
  83. --head "${{ github.head_ref }}" \
  84. --base "${{ env.DEFAULT_BRANCH }}" \
  85. | grep -o 'https://github.com/[^ ]*')
  86. # Extract PR number from URL
  87. PR_NUMBER=$(echo "$PR_URL" | grep -o '[0-9]\+$')
  88. # Set environment vars
  89. echo "PR_URL=$PR_URL" >> $GITHUB_ENV
  90. echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
  91. - name: Post Comment
  92. env:
  93. GH_TOKEN: ${{ github.token }}
  94. run: |
  95. gh issue comment ${{ github.event.issue.number }} \
  96. -b "OpenDevin raised [PR #${{ env.PR_NUMBER }}](${{ env.PR_URL }}) to resolve this issue."