π OpenHands: AI-Driven Development
Fix image tag inconsistency in forked-PR workflows (#6998)
zchnfd5e1e0b0b65
diff --git a/.github/workflows/ghcr-build.yml b/.github/workflows/ghcr-build.ymlindex 53439e0e7e..4c981013c3 100644--- a/.github/workflows/ghcr-build.yml+++ b/.github/workflows/ghcr-build.yml@@ -54,22 +54,22 @@ jobs:- name: Set up Docker Buildxid: buildxuses: docker/setup-buildx-action@v3+ - name: Lowercase Repository Owner+ run: |+ echo REPO_OWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV- name: Build and push app imageif: "!github.event.pull_request.head.repo.fork"run: |- ./containers/build.sh -i openhands -o ${{ github.repository_owner }} --push+ ./containers/build.sh -i openhands -o ${{ env.REPO_OWNER }} --push- name: Build app imageif: "github.event.pull_request.head.repo.fork"run: |- ./containers/build.sh -i openhands -o ${{ github.repository_owner }} --load+ ./containers/build.sh -i openhands -o ${{ env.REPO_OWNER }} --load- name: Get hash in App Imageid: get_hash_in_app_imagerun: |- # Lowercase the repository owner- export REPO_OWNER=${{ github.repository_owner }}- REPO_OWNER=$(echo $REPO_OWNER | tr '[:upper:]' '[:lower:]')# Run the build script in the app image- docker run -e SANDBOX_USER_ID=0 -v /var/run/docker.sock:/var/run/docker.sock ghcr.io/${REPO_OWNER}/openhands:${{ env.RELEVANT_SHA }} /bin/bash -c "mkdir -p containers/runtime; python3 openhands/runtime/utils/runtime_build.py --base_image ${{ env.BASE_IMAGE_FOR_HASH_EQUIVALENCE_TEST }} --build_folder containers/runtime --force_rebuild" 2>&1 | tee docker-outputs.txt+ docker run -e SANDBOX_USER_ID=0 -v /var/run/docker.sock:/var/run/docker.sock ghcr.io/${{ env.REPO_OWNER }}/openhands:${{ env.RELEVANT_SHA }} /bin/bash -c "mkdir -p containers/runtime; python3 openhands/runtime/utils/runtime_build.py --base_image ${{ env.BASE_IMAGE_FOR_HASH_EQUIVALENCE_TEST }} --build_folder containers/runtime --force_rebuild" 2>&1 | tee docker-outputs.txt# Get the hash from the build scripthash_from_app_image=$(cat docker-outputs.txt | grep "Hash for docker build directory" | awk -F "): " '{print $2}' | uniq | head -n1)echo "hash_from_app_image=$hash_from_app_image" >> $GITHUB_OUTPUT@@ -122,16 +122,19 @@ jobs:run: make install-python-dependencies- name: Create source distribution and Dockerfilerun: poetry run python3 openhands/runtime/utils/runtime_build.py --base_image ${{ matrix.base_image.image }} --build_folder containers/runtime --force_rebuild+ - name: Lowercase Repository Owner+ run: |+ echo REPO_OWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV- name: Build and push runtime image ${{ matrix.base_image.image }}if: github.event.pull_request.head.repo.fork != truerun: |- ./containers/build.sh -i runtime -o ${{ github.repository_owner }} --push -t ${{ matrix.base_image.tag }}+ ./containers/build.sh -i runtime -o ${{ env.REPO_OWNER }} --push -t ${{ matrix.base_image.tag }}# Forked repos can't push to GHCR, so we need to upload the image as an artifact- name: Build runtime image ${{ matrix.base_image.image }} for forkif: github.event.pull_request.head.repo.forkuses: docker/build-push-action@v6with:- tags: ghcr.io/all-hands-ai/runtime:${{ env.RELEVANT_SHA }}-${{ matrix.base_image.tag }}+ tags: ghcr.io/${{ env.REPO_OWNER }}/runtime:${{ env.RELEVANT_SHA }}-${{ matrix.base_image.tag }}outputs: type=docker,dest=/tmp/runtime-${{ matrix.base_image.tag }}.tarcontext: containers/runtime- name: Upload runtime image for fork@@ -233,6 +236,9 @@ jobs:run: pipx install poetry- name: Install Python dependencies using Poetryrun: make install-python-dependencies+ - name: Lowercase Repository Owner+ run: |+ echo REPO_OWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV- name: Run docker runtime testsrun: |# We install pytest-xdist in order to run tests across CPUs@@ -241,8 +247,7 @@ jobs:# Install to be able to retry on failures for flaky testspoetry run pip install pytest-rerunfailures- image_name=ghcr.io/${{ github.repository_owner }}/runtime:${{ env.RELEVANT_SHA }}-${{ matrix.base_image }}- image_name=$(echo $image_name | tr '[:upper:]' '[:lower:]')+ image_name=ghcr.io/${{ env.REPO_OWNER }}/runtime:${{ env.RELEVANT_SHA }}-${{ matrix.base_image }}TEST_RUNTIME=docker \SANDBOX_USER_ID=$(id -u) \@@ -296,6 +301,9 @@ jobs:run: pipx install poetry- name: Install Python dependencies using Poetryrun: make install-python-dependencies+ - name: Lowercase Repository Owner+ run: |+ echo REPO_OWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV- name: Run runtime testsrun: |# We install pytest-xdist in order to run tests across CPUs@@ -304,8 +312,7 @@ jobs:# Install to be able to retry on failures for flaky testspoetry run pip install pytest-rerunfailures- image_name=ghcr.io/${{ github.repository_owner }}/runtime:${{ env.RELEVANT_SHA }}-${{ matrix.base_image }}- image_name=$(echo $image_name | tr '[:upper:]' '[:lower:]')+ image_name=ghcr.io/${{ env.REPO_OWNER }}/runtime:${{ env.RELEVANT_SHA }}-${{ matrix.base_image }}TEST_RUNTIME=docker \SANDBOX_USER_ID=$(id -u) \