From a4792c93b26d0cc52207940547073109f8ea8e35 Mon Sep 17 00:00:00 2001 From: weyu <985695055@qq.com> Date: Tue, 22 Apr 2025 17:14:22 +0800 Subject: [PATCH] fluxcd --- .github/workflows/_push.yml | 2 +- .github/workflows/falco.yml | 31 +++---------------------------- .github/workflows/fluxcd.yml | 31 +++---------------------------- webs/fluxcd/toto.sh | 36 ++++++++++++++++++++++++------------ 4 files changed, 31 insertions(+), 69 deletions(-) diff --git a/.github/workflows/_push.yml b/.github/workflows/_push.yml index f286505..fdd2d61 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/falcosecurity/falco-website.git + /bin/bash build.sh https://github.com/fluxcd/website.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/.github/workflows/falco.yml b/.github/workflows/falco.yml index 940e6e6..cbd08c2 100644 --- a/.github/workflows/falco.yml +++ b/.github/workflows/falco.yml @@ -10,31 +10,6 @@ jobs: - uses: actions/checkout@v4 - name: Falco To-To-To run: | - set -x - - source libs/common.sh - install_aliyun_ossutil - - initdir=`pwd` - - - - cat ${initdir}/sed/* > ${initdir}/toto.sed - - for project in "https://github.com/falcosecurity/falco-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 + /bin/bash build.sh https://github.com/falcosecurity/falco-website.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/.github/workflows/fluxcd.yml b/.github/workflows/fluxcd.yml index a085997..192e1da 100644 --- a/.github/workflows/fluxcd.yml +++ b/.github/workflows/fluxcd.yml @@ -10,31 +10,6 @@ jobs: - uses: actions/checkout@v4 - name: FluxCD To-To-To run: | - set -x - - source libs/common.sh - install_aliyun_ossutil - - initdir=`pwd` - - - - cat ${initdir}/sed/* > ${initdir}/toto.sed - - for project in "https://github.com/fluxcd/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 + /bin/bash build.sh https://github.com/fluxcd/website.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/webs/fluxcd/toto.sh b/webs/fluxcd/toto.sh index 262fc22..e220fa2 100644 --- a/webs/fluxcd/toto.sh +++ b/webs/fluxcd/toto.sh @@ -1,9 +1,6 @@ -workdir=$1 -initdir=$2 - source libs/common.sh -before_flux_website(){ +before_build(){ install_hugo_v122 install_postcss @@ -12,7 +9,7 @@ before_flux_website(){ } -after_flux_website(){ +build(){ sed -i 's|PATH=$(BIN_DIR):$(PATH) BRANCH=$(BRANCH) hack/import-flux2-assets.sh|GITHUB_USER=cncfstack GITHUB_TOKEN=${{secret.CNCFSTACK_GITHUB_TOKEN}} PATH=$(BIN_DIR):$(PATH) BRANCH=$(BRANCH) hack/import-flux2-assets.sh|g' Makefile @@ -29,21 +26,36 @@ after_flux_website(){ --minify \ --gc \ --enableGitInfo \ - --baseURL https://flux.cncfstack.com + --baseURL https://flux.website.cncfstack.com } save_return(){ - ls -lha - echo "${workdir}/output&oss://cncfstack-flux" > ${workdir}/ret-data + + #echo "${workdir}/output&oss://cncfstack-flux" > ${workdir}/ret-data + # 这行很重要,在其他关联项目中,文件名称必须要匹配 + tarfile="fluxcd.tgz" + + # 进入到site目录后进行打包,这样是为了便于部署时解压 + tar -czf ${tarfile} -C output . + + if [ ! -s ${tarfile} ];then + log_error "站点构建失败" + fi + + debug_tools + + log_info "站点构建完成" + + echo "project_dir/${tarfile}" > ret-data } -cd $workdir +cd project_dir if cat .git/config |grep '/fluxcd/website.git' ;then - echo "=============================================> 匹配到 flux" - before_flux_website - after_flux_website + echo "匹配到 flux" + before_build + build find_and_sed_v2 "./output" save_return fi