mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
* Replace OpenDevin with OpenHands * Update CONTRIBUTING.md * Update README.md * Update README.md * update poetry lock; move opendevin folder to openhands * fix env var * revert image references in docs * revert permissions * revert permissions --------- Co-authored-by: Xingyao Wang <xingyao6@illinois.edu>
114 lines
3.9 KiB
YAML
114 lines
3.9 KiB
YAML
# Workflow that uses OpenHands to resolve a GitHub issue. Issue must be labeled 'solve-this'
|
|
name: Use OpenHands to Resolve GitHub Issue
|
|
|
|
on:
|
|
issues:
|
|
types: [labeled]
|
|
|
|
permissions:
|
|
contents: write
|
|
pull-requests: write
|
|
issues: write
|
|
|
|
jobs:
|
|
dogfood:
|
|
if: github.event.label.name == 'solve-this'
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: ghcr.io/all-hands-ai/openhands
|
|
volumes:
|
|
- /var/run/docker.sock:/var/run/docker.sock
|
|
steps:
|
|
- name: install git, github cli
|
|
run: apt-get install -y git gh
|
|
- name: Checkout Repository
|
|
uses: actions/checkout@v4
|
|
- name: Write Task File
|
|
env:
|
|
ISSUE_TITLE: ${{ github.event.issue.title }}
|
|
ISSUE_BODY: ${{ github.event.issue.body }}
|
|
run: |
|
|
echo "TITLE:" > task.txt
|
|
echo "${ISSUE_TITLE}" >> task.txt
|
|
echo "" >> task.txt
|
|
echo "BODY:" >> task.txt
|
|
echo "${ISSUE_BODY}" >> task.txt
|
|
- name: Set up environment
|
|
run: |
|
|
curl -sSL https://install.python-poetry.org | python3 -
|
|
export PATH="/github/home/.local/bin:$PATH"
|
|
poetry install --without evaluation,llama-index
|
|
poetry run playwright install --with-deps chromium
|
|
- name: Run OpenHands
|
|
env:
|
|
ISSUE_TITLE: ${{ github.event.issue.title }}
|
|
ISSUE_BODY: ${{ github.event.issue.body }}
|
|
LLM_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
|
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
|
run: |
|
|
# Append path to launch poetry
|
|
export PATH="/github/home/.local/bin:$PATH"
|
|
# Append path to correctly import package, note: must set pwd at first
|
|
export PYTHONPATH=$(pwd):$PYTHONPATH
|
|
WORKSPACE_MOUNT_PATH=$GITHUB_WORKSPACE poetry run python ./openhands/core/main.py -i 50 -f task.txt -d $GITHUB_WORKSPACE
|
|
rm task.txt
|
|
- name: Setup Git, Create Branch, and Commit Changes
|
|
run: |
|
|
# Setup Git configuration
|
|
git config --global --add safe.directory $PWD
|
|
git config --global user.name 'OpenHands'
|
|
git config --global user.email 'OpenHands@users.noreply.github.com'
|
|
|
|
# Create a unique branch name with a timestamp
|
|
BRANCH_NAME="fix/${{ github.event.issue.number }}-$(date +%Y%m%d%H%M%S)"
|
|
|
|
# Checkout new branch
|
|
git checkout -b $BRANCH_NAME
|
|
|
|
# Add all changes to staging, except task.txt
|
|
git add --all -- ':!task.txt'
|
|
|
|
# Commit the changes, if any
|
|
git commit -m "OpenHands: Resolve Issue #${{ github.event.issue.number }}"
|
|
if [ $? -ne 0 ]; then
|
|
echo "No changes to commit."
|
|
exit 0
|
|
fi
|
|
|
|
# Push changes
|
|
git push --set-upstream origin $BRANCH_NAME
|
|
- name: Fetch Default Branch
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
run: |
|
|
# Fetch the default branch using gh cli
|
|
DEFAULT_BRANCH=$(gh repo view --json defaultBranchRef --jq .defaultBranchRef.name)
|
|
echo "Default branch is $DEFAULT_BRANCH"
|
|
echo "DEFAULT_BRANCH=$DEFAULT_BRANCH" >> $GITHUB_ENV
|
|
- name: Generate PR
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
run: |
|
|
# Create PR and capture URL
|
|
PR_URL=$(gh pr create \
|
|
--title "OpenHands: Resolve Issue #2" \
|
|
--body "This PR was generated by OpenHands to resolve issue #2" \
|
|
--repo "foragerr/OpenHands" \
|
|
--head "${{ github.head_ref }}" \
|
|
--base "${{ env.DEFAULT_BRANCH }}" \
|
|
| grep -o 'https://github.com/[^ ]*')
|
|
|
|
# Extract PR number from URL
|
|
PR_NUMBER=$(echo "$PR_URL" | grep -o '[0-9]\+$')
|
|
|
|
# Set environment vars
|
|
echo "PR_URL=$PR_URL" >> $GITHUB_ENV
|
|
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
|
|
|
|
- name: Post Comment
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
run: |
|
|
gh issue comment ${{ github.event.issue.number }} \
|
|
-b "OpenHands raised [PR #${{ env.PR_NUMBER }}](${{ env.PR_URL }}) to resolve this issue."
|