This commit is contained in:
weyu 2025-03-29 15:49:33 +08:00
parent 68b0f66d76
commit 8ebcf8439d
5 changed files with 106 additions and 2 deletions

51
.github/workflows/etcd.yml vendored Normal file
View File

@ -0,0 +1,51 @@
name: To-To-To Etcd
on:
schedule:
- cron: "15 3 * * *"
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Etcd 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/etcd-io/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}'`
ls -lha $src
if [ -f "${src}/index.html" ];then
echo "=============================================> 构建成功上传文件到OSS"
./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
else
echo "=============================================> 没有构建出 index.html 文件"
continue
fi
done

View File

@ -12,4 +12,5 @@ https://github.com/openkruise/openkruise.io.git
https://github.com/kubevela/kubevela.github.io.git
https://github.com/volcano-sh/website.git
https://github.com/fluxcd/website.git
https://github.com/tikv/website.git
https://github.com/tikv/website.git
https://github.com/etcd-io/website.git

View File

@ -33,6 +33,15 @@ install_hugo_v122(){
sudo chmod +x /usr/bin/hugo
}
install_hugo_v145(){
echo "=============================================> 安装 Hugo V0.145.0"
wget -q https://github.com/gohugoio/hugo/releases/download/v0.145.0/hugo_extended_0.145.0_linux-amd64.tar.gz
tar xf hugo_extended_0.145.0_linux-amd64.tar.gz
sudo cp ./hugo /usr/bin/
sudo chmod +x /usr/bin/hugo
}
install_postcss(){
echo "=============================================> 安装 postCSS"
npm i -D postcss postcss-cli autoprefixer

View File

@ -1 +1 @@
https://github.com/tikv/website.git
https://github.com/etcd-io/website.git

43
webs/etcd/toto.sh Normal file
View File

@ -0,0 +1,43 @@
workdir=$1
initdir=$2
source ${initdir}/libs/common.sh
before_etcd_website(){
install_hugo_v145
install_postcss
# 添加网站访问统计
echo '<script defer src="https://umami.cncfstack.com/script.js" data-website-id="fd31286b-b455-4b8c-8d83-549b2ab02cff"></script>' >> layouts/partials/favicons.html
}
after_etcd_website(){
#npm run build:production
mkdir output
hugo \
--destination ./output \
--cleanDestinationDir \
--minify \
--gc \
--enableGitInfo \
--baseURL https://etcd.cncfstack.com
}
save_return(){
ls -lha
echo "${workdir}/output&oss://cncfstack-etcd" > ${workdir}/ret-data
}
cd $workdir
if cat .git/config |grep '/etcd-io/website.git' ;then
echo "=============================================> 匹配到 etcd"
before_etcd_website
after_etcd_website
find_and_sed_v2 "./output"
save_return
fi