From 3c5f0151c0c0cb4f74bc222d674b63f92ddfc039 Mon Sep 17 00:00:00 2001 From: okxlin <61420215+okxlin@users.noreply.github.com> Date: Sun, 4 Jun 2023 22:52:11 +0800 Subject: [PATCH] feat:Update renovate-app-version.sh --- .github/workflows/renovate-app-version.sh | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/workflows/renovate-app-version.sh b/.github/workflows/renovate-app-version.sh index 07c09e49..a05f5c75 100644 --- a/.github/workflows/renovate-app-version.sh +++ b/.github/workflows/renovate-app-version.sh @@ -1,42 +1,46 @@ #!/bin/bash -# This script copies the version from docker-compose.yml to config.json. +# 此脚本将docker-compose.yml文件中的版本号复制到config.json文件中。 app_name=$1 old_version=$2 -# find all docker-compose files under apps/$app_name (there should be only one) +# 查找/$app_name目录下的所有docker-compose文件(应该只有一个) docker_compose_files=$(find $app_name/$old_version -name docker-compose.yml) -# Declare an associative array to store excluded versions for each app_name +# 声明一个关联数组,用于存储每个app_name对应的排除版本号 declare -A excluded_versions excluded_versions["qBittorrent"]="4.3.5" excluded_versions["php-unofficial"]="all" -# Add more excluded versions if needed +# 如果需要,可以添加更多的排除版本号 +# 遍历每个docker-compose文件 for docker_compose_file in $docker_compose_files do - # Skip if app_name and version match the excluded versions + # 如果app_name和版本号匹配了排除版本号,跳过处理 if [[ "${excluded_versions[$app_name]}" == "all" ]]; then continue fi - # Assuming that the app version will be from the first docker image + # 假设应用的版本号位于第一个docker镜像的标签中 first_service=$(yq '.services | keys | .[0]' $docker_compose_file) + # 获取镜像名称 image=$(yq .services.$first_service.image $docker_compose_file) - # Only apply changes if the format is : + # 只有当镜像名称的格式为:时才应用更改 if [[ "$image" == *":"* ]]; then + # 提取版本号 version=$(cut -d ":" -f2- <<< "$image") - # Trim the "v" prefix + # 去掉版本号开头的"v"前缀 trimmed_version=${version/#"v"} - # Skip if app_name and version match the excluded versions + # 如果app_name和版本号匹配了排除版本号,跳过处理 if [[ "${excluded_versions[$app_name]}" == "$trimmed_version" ]]; then continue fi + # 将旧版本号的目录名改为提取的版本号 mv $app_name/$old_version $app_name/$trimmed_version fi done