From 1f1f28889041014137d3f0bd37dd09ef72847db2 Mon Sep 17 00:00:00 2001 From: weyu <985695055@qq.com> Date: Sun, 30 Mar 2025 19:03:40 +0800 Subject: [PATCH] add harbor --- .github/workflows/harbor.yml | 40 +++++++++++++++++++++++++++++ all.list | 3 ++- libs/common.sh | 17 ++++++++++++- push.list | 2 +- webs/harbor/toto.sh | 49 ++++++++++++++++++++++++++++++++++++ webs/linkerd/toto.sh | 44 ++++++++++++++++++++++++++++++++ 6 files changed, 152 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/harbor.yml create mode 100644 webs/harbor/toto.sh create mode 100644 webs/linkerd/toto.sh diff --git a/.github/workflows/harbor.yml b/.github/workflows/harbor.yml new file mode 100644 index 0000000..da2e240 --- /dev/null +++ b/.github/workflows/harbor.yml @@ -0,0 +1,40 @@ +name: To-To-To Harbor +on: + schedule: + - cron: "15 3 * * *" + workflow_dispatch: +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Harbor To-To-To + run: | + set -x + + source libs/aliyun.sh + install_aliyun_ossutil + + initdir=`pwd` + + source ${initdir}/libs/common.sh + + cat ${initdir}/sed/* > ${initdir}/toto.sed + + for project in "https://github.com/goharbor/website.git" + do + + uuid=`date "+%s%N"` + workdir="${initdir}/tmp/${uuid}" + mkdir -p $workdir + + git clone $project $workdir + ls $workdir + + find ./webs -name toto.sh -exec /bin/bash {} $workdir $initdir \; + + src=`cat ${workdir}/ret-data|grep -v ^$|head -n 1|awk -F'&' '{print $1}'` + dest=`cat ${workdir}/ret-data|grep -v ^$|head -n 1|awk -F'&' '{print $2}'` + + ./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 -fr $src $dest + done \ No newline at end of file diff --git a/all.list b/all.list index 35780c2..6ceeef0 100644 --- a/all.list +++ b/all.list @@ -22,4 +22,5 @@ https://github.com/emissary-ingress/emissary-ingress.dev.git https://github.com/crossplane/docs.git https://github.com/kedacore/keda-docs.git https://github.com/kubeflow/website.git -https://github.com/istio/istio.io.git \ No newline at end of file +https://github.com/istio/istio.io.git +https://github.com/goharbor/website.git \ No newline at end of file diff --git a/libs/common.sh b/libs/common.sh index cfd677e..23c12ac 100755 --- a/libs/common.sh +++ b/libs/common.sh @@ -16,6 +16,15 @@ install_hugo_v66(){ sudo chmod +x /usr/bin/hugo } +install_hugo_v74(){ + echo "=============================================> 安装 Hugo V0.74.0" + wget -q https://github.com/gohugoio/hugo/releases/download/v0.74.0/hugo_extended_0.74.0_Linux-64bit.tar.gz + tar xf hugo_extended_0.74.0_Linux-64bit.tar.gz + sudo cp ./hugo /usr/bin/ + sudo chmod +x /usr/bin/hugo +} + + install_hugo_v93_2(){ echo "=============================================> 安装 Hugo V0.93.2" wget -q https://github.com/gohugoio/hugo/releases/download/v0.93.2/hugo_extended_0.93.2_Linux-64bit.tar.gz @@ -76,6 +85,13 @@ install_hugo_v124_1(){ sudo chmod +x /usr/bin/hugo } +install_hugo_v136_5(){ + echo "=============================================> 安装 Hugo V0.136.5" + wget -q https://github.com/gohugoio/hugo/releases/download/v0.136.5/hugo_extended_0.136.5_linux-amd64.tar.gz + tar xf hugo_extended_0.136.5_linux-amd64.tar.gz + sudo cp ./hugo /usr/bin/ + sudo chmod +x /usr/bin/hugo +} install_hugo_v139_3(){ echo "=============================================> 安装 Hugo V0.139.3" wget -q https://github.com/gohugoio/hugo/releases/download/v0.139.3/hugo_extended_0.139.3_linux-amd64.tar.gz @@ -84,7 +100,6 @@ install_hugo_v139_3(){ sudo chmod +x /usr/bin/hugo } - install_hugo_v143_1(){ echo "=============================================> 安装 Hugo V0.143.1" wget -q https://github.com/gohugoio/hugo/releases/download/v0.143.1/hugo_extended_0.143.1_linux-amd64.tar.gz diff --git a/push.list b/push.list index eb8a60a..519f1a8 100644 --- a/push.list +++ b/push.list @@ -1 +1 @@ -https://github.com/istio/istio.io.git \ No newline at end of file +https://github.com/goharbor/website.git \ No newline at end of file diff --git a/webs/harbor/toto.sh b/webs/harbor/toto.sh new file mode 100644 index 0000000..457b1f8 --- /dev/null +++ b/webs/harbor/toto.sh @@ -0,0 +1,49 @@ +workdir=$1 +initdir=$2 + +source ${initdir}/libs/common.sh + +before_harbor_website(){ + install_hugo_v74 + install_postcss + + make prepare + npm i + + + # 添加网站访问统计 + echo '' >> layouts/partials/favicon.html + +} + +after_harbor_website(){ + + #npm run build:production + + mkdir output + hugo \ + --destination ./output \ + --cleanDestinationDir \ + --buildDrafts \ + --buildFuture \ + --minify \ + --gc \ + --enableGitInfo \ + --baseURL https://harbor.cncfstack.com + +} + +save_return(){ + ls -lha + echo "${workdir}/output&oss://cncfstack-harbor" > ${workdir}/ret-data +} + + +cd $workdir +if cat .git/config |grep '/goharbor/website.git' ;then + echo "=============================================> 匹配到 harbor" + before_harbor_website + after_harbor_website + find_and_sed_v2 "./output" + save_return +fi diff --git a/webs/linkerd/toto.sh b/webs/linkerd/toto.sh new file mode 100644 index 0000000..1ce1e6b --- /dev/null +++ b/webs/linkerd/toto.sh @@ -0,0 +1,44 @@ +workdir=$1 +initdir=$2 + +source ${initdir}/libs/common.sh + +before_istio_website(){ + + install_hugo_v136_5 + install_postcss + + # 添加网站访问统计 + + sed -i 's|||g' layouts/_default/baseof.html + +} + +after_istio_website(){ + + mkdir output + hugo \ + --destination ./output \ + --cleanDestinationDir \ + --minify \ + --gc \ + --enableGitInfo \ + --baseURL https://istio.cncfstack.com + +} + +save_return(){ + ls -lha + pwd + echo "${workdir}/output&oss://cncfstack-istio" > ${workdir}/ret-data +} + + +cd $workdir +if cat .git/config |grep '/istio/istio.io.git' ;then + echo "=============================================> 匹配到 istio" + before_istio_website + after_istio_website + find_and_sed_v2 "./output" + save_return +fi