From 99dd3d9691f26a56905dc92069927532b7fd9ee9 Mon Sep 17 00:00:00 2001 From: Lan Liang Date: Mon, 21 Apr 2025 13:47:01 +0800 Subject: [PATCH] chore: add script for repush. Signed-off-by: Lan Liang --- scripts/repush_not_exist.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 scripts/repush_not_exist.sh diff --git a/scripts/repush_not_exist.sh b/scripts/repush_not_exist.sh new file mode 100644 index 00000000..b4aabdef --- /dev/null +++ b/scripts/repush_not_exist.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +# Traverse the k8s directory under kcl-artifacthub +find $(pwd) -mindepth 1 -maxdepth 2 -type d | while read -r dir; do + # Check if the .mod file exists in the current directory + if [ -f "$dir/kcl.mod" ]; then + echo "Contents of $dir/kcl.mod:" + + # Extract and print the 'name' field + name=$(grep -m 1 '^name' "$dir/kcl.mod" | awk -F '=' '{print $2}' | xargs) + # Extract and print the 'version' field + version=$(grep -m 1 '^version' "$dir/kcl.mod" | awk -F '=' '{print $2}' | xargs) + + IMAGE_EXIST=`oras manifest fetch ghcr.io/kcl-lang/$name:$version | grep mediaType | wc -l ` + if [ $IMAGE_EXIST -eq 1 ]; then + echo "" + else + echo "$name:$version is not exist!" + ./scripts/push_pkg_from.sh $dir/kcl.mod + fi + fi +done \ No newline at end of file