From 7478b593490f47f49aa5227f4790b2f76bb13471 Mon Sep 17 00:00:00 2001 From: jinglinwei Date: Tue, 20 May 2025 00:28:06 +0800 Subject: [PATCH 1/3] chore(graphrag): support incubator-hugegraph-ai --- .../publish_latest_graphrag_image.yml | 85 +++++++++++++++++++ .../publish_release_graphrag_image.yml | 64 ++++++++++++++ 2 files changed, 149 insertions(+) create mode 100644 .github/workflows/publish_latest_graphrag_image.yml create mode 100644 .github/workflows/publish_release_graphrag_image.yml diff --git a/.github/workflows/publish_latest_graphrag_image.yml b/.github/workflows/publish_latest_graphrag_image.yml new file mode 100644 index 0000000..4f27289 --- /dev/null +++ b/.github/workflows/publish_latest_graphrag_image.yml @@ -0,0 +1,85 @@ +name: "Publish graphrag image(latest)" + +on: + workflow_dispatch: + schedule: + - cron: '0 23 * * *' + +jobs: + build_latest: + runs-on: ubuntu-latest + env: + REPOSITORY_URL: apache/incubator-hugegraph-ai + BRANCH: master + IMAGE_URL: hugegraph/graphrag:latest + IMAGE_URL_NK: hugegraph/graphrag_nk:latest + GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + OWNER: hugegraph + REPO: actions + LAST_AI_HASH: ${{vars.LAST_AI_HASH}} + + steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Checkout latest + uses: actions/checkout@v4 + with: + repository: ${{ env.REPOSITORY_URL }} + ref: ${{ env.BRANCH }} + fetch-depth: 2 + + - name: Get current commit-hash + run: | + current_commit_hash=$(git rev-parse HEAD) + echo "CURRENT_COMMIT_HASH=$current_commit_hash" >> $GITHUB_ENV + + - name: Check if an update is needed + run: | + need_update='false' + if [[ "$CURRENT_COMMIT_HASH" != "$LAST_AI_HASH" ]]; then + need_update='true' + fi + echo "NEED_UPDATE=$need_update" >> $GITHUB_ENV + # TODO: replace the `if` statements with a graceful exit once GitHub Actions supports it. + # See https://github.com/actions/runner/issues/662 for more details. + + - name: Build X86 & ARM And Push All + uses: docker/build-push-action@v5 + if: ${{ env.NEED_UPDATE == 'true' }} + with: + context: . + file: ./docker/Dockerfile.llm + platforms: linux/amd64,linux/arm64 + tags: ${{ env.IMAGE_URL }} + push: true + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Build Binary X86 & ARM And Push All + uses: docker/build-push-action@v5 + if: ${{ env.NEED_UPDATE == 'true' }} + with: + context: . + file: ./docker/Dockerfile.nk + platforms: linux/amd64,linux/arm64 + tags: ${{ env.IMAGE_URL_NK }} + push: true + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Update last commit-hash + if: ${{ env.NEED_UPDATE == 'true' }} + run: | + curl -L -X PATCH \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + -H "Authorization: Bearer $GITHUB_TOKEN" \ + https://api.github.com/repos/$OWNER/$REPO/actions/variables/LAST_AI_HASH \ + -d '{"name":"LAST_AI_HASH","value":"'"$CURRENT_COMMIT_HASH"'"}' diff --git a/.github/workflows/publish_release_graphrag_image.yml b/.github/workflows/publish_release_graphrag_image.yml new file mode 100644 index 0000000..c5f5b21 --- /dev/null +++ b/.github/workflows/publish_release_graphrag_image.yml @@ -0,0 +1,64 @@ +name: "Publish graphrag image(release)" +on: + workflow_dispatch: + inputs: + branch: + required: true + default: '' + description: 'The branch name should be like *-x.x.x, for example release-1.0.0' + +jobs: + build_latest: + runs-on: ubuntu-latest + env: + REPOSITORY_URL: apache/incubator-hugegraph-ai + BRANCH: ${{inputs.branch}} + + steps: + - name: Set image_url + run: | + image_url=hugegraph/graphrag:$(echo "${{ inputs.branch }}" | grep -oP '(\d+\.\d+\.\d+)') + echo $image_url && echo "IMAGE_URL=$image_url" >> $GITHUB_ENV + + - name: Set image_url_nk + run: | + image_url_nk=hugegraph/graphrag_nk:$(echo "${{ inputs.branch }}" | grep -oP '(\d+\.\d+\.\d+)') + echo $image_url_nk && echo "IMAGE_URL_NK=$image_url_nk" >> $GITHUB_ENV + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Checkout latest + uses: actions/checkout@v4 + with: + repository: ${{ env.REPOSITORY_URL }} + ref: ${{ env.BRANCH }} + fetch-depth: 2 + + - name: Build X86 &ARM And Push All + uses: docker/build-push-action@v5 + with: + context: . + file: ./docker/Dockerfile.llm + platforms: linux/amd64,linux/arm64 + tags: ${{ env.IMAGE_URL }} + push: true + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Build Binary X86 &ARM And Push All + uses: docker/build-push-action@v5 + with: + context: . + file: ./docker/Dockerfile.nk + platforms: linux/amd64,linux/arm64 + tags: ${{ env.IMAGE_URL_NK }} + push: true + cache-from: type=gha + cache-to: type=gha,mode=max From 306e2a05b7674bbd5b00287562419021eeefb380 Mon Sep 17 00:00:00 2001 From: Linyu <94553312+weijinglin@users.noreply.github.com> Date: Wed, 21 May 2025 00:11:15 +0800 Subject: [PATCH 2/3] Update publish_release_graphrag_image.yml --- .github/workflows/publish_release_graphrag_image.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish_release_graphrag_image.yml b/.github/workflows/publish_release_graphrag_image.yml index c5f5b21..865bf62 100644 --- a/.github/workflows/publish_release_graphrag_image.yml +++ b/.github/workflows/publish_release_graphrag_image.yml @@ -17,9 +17,8 @@ jobs: steps: - name: Set image_url run: | - image_url=hugegraph/graphrag:$(echo "${{ inputs.branch }}" | grep -oP '(\d+\.\d+\.\d+)') - echo $image_url && echo "IMAGE_URL=$image_url" >> $GITHUB_ENV - + version=$(echo "${{ inputs.branch }}" | grep -oP '(\d+\.\d+\.\d+)') || exit 1 + echo "IMAGE_URL=hugegraph/graphrag:$version" >> $GITHUB_ENV - name: Set image_url_nk run: | image_url_nk=hugegraph/graphrag_nk:$(echo "${{ inputs.branch }}" | grep -oP '(\d+\.\d+\.\d+)') From 4b4ab8942fe3013724ac6e763b2e28acd5439fa6 Mon Sep 17 00:00:00 2001 From: imbajin Date: Wed, 21 May 2025 18:46:34 +0800 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/publish_latest_graphrag_image.yml | 6 +++--- .github/workflows/publish_release_graphrag_image.yml | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/publish_latest_graphrag_image.yml b/.github/workflows/publish_latest_graphrag_image.yml index 4f27289..6cff304 100644 --- a/.github/workflows/publish_latest_graphrag_image.yml +++ b/.github/workflows/publish_latest_graphrag_image.yml @@ -1,4 +1,4 @@ -name: "Publish graphrag image(latest)" +name: "Publish Graph-AI Image(latest)" on: workflow_dispatch: @@ -11,8 +11,8 @@ jobs: env: REPOSITORY_URL: apache/incubator-hugegraph-ai BRANCH: master - IMAGE_URL: hugegraph/graphrag:latest - IMAGE_URL_NK: hugegraph/graphrag_nk:latest + IMAGE_URL: hugegraph/rag:latest + IMAGE_URL_NK: hugegraph/rag-bin:latest GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} OWNER: hugegraph REPO: actions diff --git a/.github/workflows/publish_release_graphrag_image.yml b/.github/workflows/publish_release_graphrag_image.yml index 865bf62..2d8ed46 100644 --- a/.github/workflows/publish_release_graphrag_image.yml +++ b/.github/workflows/publish_release_graphrag_image.yml @@ -1,4 +1,4 @@ -name: "Publish graphrag image(release)" +name: "Publish AI Image(release)" on: workflow_dispatch: inputs: @@ -18,10 +18,10 @@ jobs: - name: Set image_url run: | version=$(echo "${{ inputs.branch }}" | grep -oP '(\d+\.\d+\.\d+)') || exit 1 - echo "IMAGE_URL=hugegraph/graphrag:$version" >> $GITHUB_ENV + echo "IMAGE_URL=hugegraph/rag:$version" >> $GITHUB_ENV - name: Set image_url_nk run: | - image_url_nk=hugegraph/graphrag_nk:$(echo "${{ inputs.branch }}" | grep -oP '(\d+\.\d+\.\d+)') + image_url_nk=hugegraph/rag-bin:$(echo "${{ inputs.branch }}" | grep -oP '(\d+\.\d+\.\d+)') echo $image_url_nk && echo "IMAGE_URL_NK=$image_url_nk" >> $GITHUB_ENV - name: Set up Docker Buildx @@ -40,7 +40,7 @@ jobs: ref: ${{ env.BRANCH }} fetch-depth: 2 - - name: Build X86 &ARM And Push All + - name: Build X86 & ARM and Push All uses: docker/build-push-action@v5 with: context: . @@ -51,7 +51,7 @@ jobs: cache-from: type=gha cache-to: type=gha,mode=max - - name: Build Binary X86 &ARM And Push All + - name: Build Binary X86 & ARM and Push All uses: docker/build-push-action@v5 with: context: .