Skip to content

Commit 035f39f

Browse files
authored
weekly update images tag (#667)
Signed-off-by: Sun, Xuehao <xuehao.sun@intel.com>
1 parent 6f3e54a commit 035f39f

File tree

3 files changed

+67
-52
lines changed

3 files changed

+67
-52
lines changed

.github/workflows/manual-freeze-images.yml

Lines changed: 0 additions & 43 deletions
This file was deleted.

.github/workflows/scripts/freeze_images.sh renamed to .github/workflows/scripts/update_images_tag.sh

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,18 @@
44
# SPDX-License-Identifier: Apache-2.0
55

66
declare -A dict
7-
dict["langchain/langchain"]="docker://docker.io/langchain/langchain"
8-
dict["ghcr.io/huggingface/text-generation-inference"]="docker://ghcr.io/huggingface/text-generation-inference"
7+
dict["ghcr.io/huggingface/text-generation-inference"]="docker://ghcr.io/huggingface/text-generation-inference:latest-intel-cpu"
98

109
function get_latest_version() {
1110
repo_image=$1
12-
versions=$(skopeo list-tags ${dict[$repo_image]} | jq -r '.Tags[]')
13-
printf "version list:\n$versions\n"
14-
latest_version=$(printf "%s\n" "${versions[@]}" | grep -E '^[\.0-9\-]+$' | sort -V | tail -n 1)
11+
if [[ $repo_image == *"huggingface"* ]]; then
12+
revision=$(skopeo inspect --config ${dict[$repo_image]} | jq -r '.config.Labels["org.opencontainers.image.revision"][:7]')
13+
latest_version="sha-$revision-intel-cpu"
14+
else
15+
versions=$(skopeo list-tags ${dict[$repo_image]} | jq -r '.Tags[]')
16+
printf "version list:\n$versions\n"
17+
latest_version=$(printf "%s\n" "${versions[@]}" | grep -E '^[\.0-9\-]+$' | sort -V | tail -n 1)
18+
fi
1519
echo "latest version: $latest_version"
1620
replace_image_version $repo_image $latest_version
1721
}
@@ -22,10 +26,10 @@ function replace_image_version() {
2226
if [[ -z "$version" ]]; then
2327
echo "version is empty"
2428
else
25-
echo "replace $repo_image:latest with $repo_image:$version"
26-
find . -name "Dockerfile" | xargs sed -i "s|$repo_image:latest.*|$repo_image:$version|g"
27-
find . -name "*.yaml" | xargs sed -i "s|$repo_image:latest[A-Za-z0-9\-]*|$repo_image:$version|g"
28-
find . -name "*.md" | xargs sed -i "s|$repo_image:latest[A-Za-z0-9\-]*|$repo_image:$version|g"
29+
echo "replace $repo_image:tag with $repo_image:$version"
30+
find . -name "Dockerfile" | xargs sed -i "s|$repo_image:sha[A-Za-z0-9\-]*|$repo_image:$version|g"
31+
find . -name "*.yaml" | xargs sed -i "s|$repo_image:sha[A-Za-z0-9\-]*|$repo_image:$version|g"
32+
find . -name "*.md" | xargs sed -i "s|$repo_image:sha[A-Za-z0-9\-]*|$repo_image:$version|g"
2933
fi
3034
}
3135

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Copyright (C) 2024 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
name: Weekly update base images and 3rd party images
5+
6+
on:
7+
schedule:
8+
- cron: "0 0 * * 0"
9+
workflow_dispatch:
10+
11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
15+
jobs:
16+
freeze-images:
17+
runs-on: ubuntu-latest
18+
env:
19+
USER_NAME: "NeuralChatBot"
20+
USER_EMAIL: "grp_neural_chat_bot@intel.com"
21+
BRANCH_NAME: "update_images_tag"
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
27+
ref: "main"
28+
29+
- name: Install skopeo
30+
run: |
31+
sudo apt update
32+
sudo apt -y install skopeo
33+
34+
- name: Set up Git
35+
run: |
36+
git config --global user.name ${{ env.USER_NAME }}
37+
git config --global user.email ${{ env.USER_EMAIL }}
38+
git remote set-url origin https://${{ env.USER_NAME }}:"${{ secrets.ACTION_TOKEN }}"@github.com/opea-project/GenAIExamples.git
39+
git checkout -b ${{ env.BRANCH_NAME }}
40+
41+
- name: Run script
42+
run: |
43+
bash .github/workflows/scripts/update_images_tag.sh
44+
45+
- name: Commit changes
46+
run: |
47+
git add .
48+
git commit -s -m "Update third party images tag"
49+
git push --set-upstream origin update_images_tag
50+
51+
- name: create pull request
52+
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'
53+
env:
54+
GITHUB_TOKEN: ${{ secrets.ACTION_TOKEN }}

0 commit comments

Comments
 (0)