From cab2c19de9a091aa6a1bc2d42151aa52eca5a314 Mon Sep 17 00:00:00 2001 From: weyu <985695055@qq.com> Date: Fri, 25 Apr 2025 17:29:34 +0800 Subject: [PATCH] knative fix --- .github/workflows/_push.yml | 2 +- libs/common.sh | 39 +++++++++++++++++++++++++++++++++++++ webs/knative/toto.sh | 2 +- 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/.github/workflows/_push.yml b/.github/workflows/_push.yml index dd4dc87..32a0a33 100644 --- a/.github/workflows/_push.yml +++ b/.github/workflows/_push.yml @@ -10,6 +10,6 @@ jobs: - uses: actions/checkout@v4 - name: Push To-To-To run: | - /bin/bash build.sh https://github.com/jaegertracing/documentation.git + /bin/bash build.sh /knative/docs.git src=`cat project_dir/ret-data|grep -v ^$|head -n 1` ./ossutil --access-key-id ${{ secrets.ALIYUN_CYG_OSS_AK }} --access-key-secret ${{ secrets.ALIYUN_CYG_OSS_SK }} --endpoint ${{ secrets.ALIYUN_CYG_OSS_ENDPOINT }} --region ${{ secrets.ALIYUN_CYG_OSS_REGION }} cp -f ${src} oss://cncfstack-website/ \ No newline at end of file diff --git a/libs/common.sh b/libs/common.sh index 6e9dad6..42b3b4e 100644 --- a/libs/common.sh +++ b/libs/common.sh @@ -284,4 +284,43 @@ cycle_sed(){ log_info "$file 文件被替换" cat $file done +} + + +filetoto(){ + + path=$1 + + find $path -type f > /tmp/sed-file-list + + log_info "/tmp/sed-file-list 文件内容" + cat /tmp/sed-file-list + + curl -fsSL https://raw.githubusercontent.com/cncfstack/filetoto/refs/heads/main/static.file -o /tmp/static.file + curl -fsSL https://raw.githubusercontent.com/cncfstack/filetoto/refs/heads/main/special.file-and-sed -o /tmp/special.file-and-sed + + + + cat /tmp/static.file|awk -F'https://' '{print "s|"$0"|https://filetoto.cncfstack.com/"$2"|g"}' > /tmp/toto.sed + cat /tmp/special.file-and-sed >> /tmp/toto.sed + + + log_info "/tmp/toto.sed 文件内容" + cat /tmp/toto.sed + + # 循环依次处理可能包含外部链接的文件,并进行替换 + for file in `cat /tmp/sed-file-list` + do + file -b $file |grep "text" + if [ $? -ne 0 ];then + log_info "NOT ASCII text, Just Skip: $file" + continue + fi + sudo sed -i -f /tmp/toto.sed $file + + # 部分CSS引用时会添加完整性校验,修改了文件后不删除校验会导致浏览器拒绝处理 + sed -i 's/integrity="[^"]*"//g' $file + + log_info "$file 文件被替换" + done } \ No newline at end of file diff --git a/webs/knative/toto.sh b/webs/knative/toto.sh index 78969ff..0c2de34 100644 --- a/webs/knative/toto.sh +++ b/webs/knative/toto.sh @@ -51,6 +51,6 @@ if cat .git/config |grep '/knative/docs.git' ;then log_info "匹配到 knative" before_build build - find_and_sed_v2 "./build" + filetoto "./build" save_return fi