From fbc1e1eac5a7bc7e2e486b926fd2adcb9c7eb7c4 Mon Sep 17 00:00:00 2001 From: "Sun, Xuehao" Date: Thu, 29 Aug 2024 10:27:06 +0800 Subject: [PATCH] weekly update images tag (#667) Signed-off-by: Sun, Xuehao --- .github/workflows/manual-freeze-images.yml | 43 --------------- ...{freeze_images.sh => update_images_tag.sh} | 22 ++++---- .github/workflows/weekly-update-images.yml | 54 +++++++++++++++++++ 3 files changed, 67 insertions(+), 52 deletions(-) delete mode 100644 .github/workflows/manual-freeze-images.yml rename .github/workflows/scripts/{freeze_images.sh => update_images_tag.sh} (53%) create mode 100644 .github/workflows/weekly-update-images.yml diff --git a/.github/workflows/manual-freeze-images.yml b/.github/workflows/manual-freeze-images.yml deleted file mode 100644 index f974340f3b..0000000000 --- a/.github/workflows/manual-freeze-images.yml +++ /dev/null @@ -1,43 +0,0 @@ -# Copyright (C) 2024 Intel Corporation -# SPDX-License-Identifier: Apache-2.0 - -name: Freeze base images and 3rd party images on manual event - -on: - workflow_dispatch: - -jobs: - freeze-images: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 - ref: ${{ github.ref }} - - - uses: actions/setup-python@v5 - with: - python-version: "3.10" - - - name: install skopeo - run: | - sudo apt update - sudo apt -y install skopeo - - - name: Set up Git - run: | - git config --global user.name "NeuralChatBot" - git config --global user.email "grp_neural_chat_bot@intel.com" - git remote set-url origin https://NeuralChatBot:"${{ secrets.ACTION_TOKEN }}"@github.com/opea-project/GenAIExamples.git - - - name: Run script - run: | - bash .github/workflows/scripts/freeze_images.sh - - - name: Commit changes - run: | - git add . - git commit -s -m "Freeze third party images tag" - git push diff --git a/.github/workflows/scripts/freeze_images.sh b/.github/workflows/scripts/update_images_tag.sh similarity index 53% rename from .github/workflows/scripts/freeze_images.sh rename to .github/workflows/scripts/update_images_tag.sh index a6beff89fa..e28b57db40 100644 --- a/.github/workflows/scripts/freeze_images.sh +++ b/.github/workflows/scripts/update_images_tag.sh @@ -4,14 +4,18 @@ # SPDX-License-Identifier: Apache-2.0 declare -A dict -dict["langchain/langchain"]="docker://docker.io/langchain/langchain" -dict["ghcr.io/huggingface/text-generation-inference"]="docker://ghcr.io/huggingface/text-generation-inference" +dict["ghcr.io/huggingface/text-generation-inference"]="docker://ghcr.io/huggingface/text-generation-inference:latest-intel-cpu" function get_latest_version() { repo_image=$1 - versions=$(skopeo list-tags ${dict[$repo_image]} | jq -r '.Tags[]') - printf "version list:\n$versions\n" - latest_version=$(printf "%s\n" "${versions[@]}" | grep -E '^[\.0-9\-]+$' | sort -V | tail -n 1) + if [[ $repo_image == *"huggingface"* ]]; then + revision=$(skopeo inspect --config ${dict[$repo_image]} | jq -r '.config.Labels["org.opencontainers.image.revision"][:7]') + latest_version="sha-$revision-intel-cpu" + else + versions=$(skopeo list-tags ${dict[$repo_image]} | jq -r '.Tags[]') + printf "version list:\n$versions\n" + latest_version=$(printf "%s\n" "${versions[@]}" | grep -E '^[\.0-9\-]+$' | sort -V | tail -n 1) + fi echo "latest version: $latest_version" replace_image_version $repo_image $latest_version } @@ -22,10 +26,10 @@ function replace_image_version() { if [[ -z "$version" ]]; then echo "version is empty" else - echo "replace $repo_image:latest with $repo_image:$version" - find . -name "Dockerfile" | xargs sed -i "s|$repo_image:latest.*|$repo_image:$version|g" - find . -name "*.yaml" | xargs sed -i "s|$repo_image:latest[A-Za-z0-9\-]*|$repo_image:$version|g" - find . -name "*.md" | xargs sed -i "s|$repo_image:latest[A-Za-z0-9\-]*|$repo_image:$version|g" + echo "replace $repo_image:tag with $repo_image:$version" + find . -name "Dockerfile" | xargs sed -i "s|$repo_image:sha[A-Za-z0-9\-]*|$repo_image:$version|g" + find . -name "*.yaml" | xargs sed -i "s|$repo_image:sha[A-Za-z0-9\-]*|$repo_image:$version|g" + find . -name "*.md" | xargs sed -i "s|$repo_image:sha[A-Za-z0-9\-]*|$repo_image:$version|g" fi } diff --git a/.github/workflows/weekly-update-images.yml b/.github/workflows/weekly-update-images.yml new file mode 100644 index 0000000000..520c4780bd --- /dev/null +++ b/.github/workflows/weekly-update-images.yml @@ -0,0 +1,54 @@ +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +name: Weekly update base images and 3rd party images + +on: + schedule: + - cron: "0 0 * * 0" + workflow_dispatch: + +permissions: + contents: write + pull-requests: write + +jobs: + freeze-images: + runs-on: ubuntu-latest + env: + USER_NAME: "NeuralChatBot" + USER_EMAIL: "grp_neural_chat_bot@intel.com" + BRANCH_NAME: "update_images_tag" + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: "main" + + - name: Install skopeo + run: | + sudo apt update + sudo apt -y install skopeo + + - name: Set up Git + run: | + git config --global user.name ${{ env.USER_NAME }} + git config --global user.email ${{ env.USER_EMAIL }} + git remote set-url origin https://${{ env.USER_NAME }}:"${{ secrets.ACTION_TOKEN }}"@github.com/opea-project/GenAIExamples.git + git checkout -b ${{ env.BRANCH_NAME }} + + - name: Run script + run: | + bash .github/workflows/scripts/update_images_tag.sh + + - name: Commit changes + run: | + git add . + git commit -s -m "Update third party images tag" + git push --set-upstream origin update_images_tag + + - name: create pull request + run: gh pr create -B main -H ${{ env.BRANCH_NAME }} --title 'Update ghcr.io/huggingface/text-generation-inference image tag' --body 'Created by Github action' + env: + GITHUB_TOKEN: ${{ secrets.ACTION_TOKEN }}