From 896572017db80182baececd2502485d7f52cf6a7 Mon Sep 17 00:00:00 2001 From: 7Wate Date: Fri, 6 Sep 2024 11:22:44 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B9=E7=9B=AE:=20=E6=9B=B4=E6=96=B0=20work?= =?UTF-8?q?flow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/build.yml | 51 ------------------------------------- .github/workflows/build.yml | 39 ++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 51 deletions(-) delete mode 100644 .github/build.yml create mode 100644 .github/workflows/build.yml diff --git a/.github/build.yml b/.github/build.yml deleted file mode 100644 index 01493621..00000000 --- a/.github/build.yml +++ /dev/null @@ -1,51 +0,0 @@ -name: Build and Deploy Quartz Site - -on: - push: - branches: [ main ] - -jobs: - build-and-deploy: - runs-on: ubuntu-latest - steps: - - name: Clone repository (quartz) - run: git clone https://github.com/7Wate/wiki-quartz.git /wiki/quartz - - - name: Clone repository (wiki) - run: git clone https://github.com/7Wate/wiki.git /wiki/quartz/content - - - name: Set up Node.js 20 - uses: actions/setup-node@v2 - with: - node-version: '20' - - - name: Install Quartz dependencies and Build site - run: | - # 设置 README 为首页,并且添加标题 - mv /wiki/quartz/content/README.md /wiki/quartz/content/index.md - sed -i '1i ---\ntitle: X·Eden\n---' /wiki/quartz/content/index.md - - # 进入 Quartz 项目目录,安装依赖并构建网站 - cd /wiki/quartz && npm ci && npx quartz build - - # 创建 public 目录并复制构建结果到此目录 - mkdir -p /wiki/public/ && cp -r public/* /wiki/public/ - - - name: Deploy to HTML branch of current repository (A仓库) - run: | - # 设置 Git 用户名和邮箱 - git config --global user.name "Github Actions" - git config --global user.email "zhouzhongping@7wate.com" - - # 在 public 目录下初始化 git 仓库 - cd /wiki/public/ && git init && git add . - - # 获取当天日期作为提交信息 - DATE=`date '+%Y-%m-%d'` - git commit -m "Deploy HTML files - $DATE" - - # 添加远程仓库地址 - git remote add gitea https://${{ secrets.GITEA_PUSH_PULL_TOKEN }}@git.7wate.com/zhouzhongping/wiki.git - - # 强制推送到远程的 html 分支 - git checkout -b quartz && git push gitea quartz --force \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..dcf519a3 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,39 @@ +name: Build and Deploy Quartz Site + +on: + push: + branches: [ main ] + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + steps: + - name: Clean up existing directories + run: rm -rf $HOME/wiki + + - name: Clone repositories + run: | + git clone https://github.com/7Wate/wiki-quartz.git $HOME/wiki/quartz && rm -rf $HOME/wiki/quartz/content + git clone https://github.com/7Wate/wiki.git $HOME/wiki/quartz/content + + - name: Set up Node.js 20 + uses: actions/setup-node@v2 + with: + node-version: '20' + + - name: Install dependencies and build site + run: | + mv $HOME/wiki/quartz/content/README.md $HOME/wiki/quartz/content/index.md + sed -i '1d' $HOME/wiki/quartz/content/index.md && sed -i '1i ---\ntitle: 数字花园\n---' $HOME/wiki/quartz/content/index.md + cd $HOME/wiki/quartz && npm ci && npx quartz build + mkdir -p $HOME/wiki/public/ && cp -r public/* $HOME/wiki/public/ + + - name: Deploy to Gitea + run: | + git config --global user.name "Github Actions" + git config --global user.email "zhouzhongping@7wate.com" + cd $HOME/wiki/public/ && git init && git add . + DATE=`date '+%Y-%m-%d'` + git commit -m "Deploy HTML files - $DATE" + git remote add gitea https://${{ secrets.GITEA_PUSH_PULL_TOKEN }}@git.7wate.com/zhouzhongping/wiki.git + git checkout -b quartz && git push gitea quartz --force \ No newline at end of file