1
0
wiki/.gitea/workflows/cicd.yaml

50 lines
1.7 KiB
YAML

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://${{ secrets.GIT_PUSH_PULL_TOKEN }}@git.7wate.com/zhouzhongping/quartz-wiki.git /wiki/quartz
- name: Clone repository (wiki)
run: git clone https://${{ secrets.GIT_PUSH_PULL_TOKEN }}@git.7wate.com/zhouzhongping/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: |
# 移除 Quartz 项目 content 目录下的 README 文件
rm -f /wiki/quartz/content/README.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 "Actions"
git config --global user.email "actions@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 origin https://${{ secrets.GIT_PUSH_PULL_TOKEN }}@git.7wate.com/zhouzhongping/wiki.git
# 强制推送到远程的 html 分支
git checkout -b quartz && git push origin quartz --force