Skip to content

Commit

Permalink
weekly update images tag (#667)
Browse files Browse the repository at this point in the history
Signed-off-by: Sun, Xuehao <[email protected]>
  • Loading branch information
XuehaoSun authored Aug 29, 2024
1 parent 6f3e54a commit 035f39f
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 52 deletions.
43 changes: 0 additions & 43 deletions .github/workflows/manual-freeze-images.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}

Expand Down
54 changes: 54 additions & 0 deletions .github/workflows/weekly-update-images.yml
Original file line number Diff line number Diff line change
@@ -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: "[email protected]"
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 }}

0 comments on commit 035f39f

Please sign in to comment.