1
0
wiki/.github/workflows/build.yml

51 lines
1.8 KiB
YAML
Raw Normal View History

2024-01-10 16:40:48 +08:00
name: Build and Deploy Quartz Site
on:
push:
2024-09-06 10:57:21 +08:00
branches: [ test ]
2024-01-10 16:40:48 +08:00
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
2024-01-10 17:33:34 +08:00
- name: Clone repository (quartz)
2024-09-06 10:57:21 +08:00
run: git clone https://github.com/7Wate/wiki-quartz.git $HOME/wiki/quartz && rm -rf $HOME/wiki/quartz/content
2024-01-10 17:33:34 +08:00
- name: Clone repository (wiki)
2024-09-06 10:54:09 +08:00
run: git clone https://github.com/7Wate/wiki.git $HOME/wiki/quartz/content
2024-01-10 16:40:48 +08:00
2024-01-10 17:33:34 +08:00
- name: Set up Node.js 20
2024-01-10 16:40:48 +08:00
uses: actions/setup-node@v2
with:
node-version: '20'
- name: Install Quartz dependencies and Build site
run: |
2024-09-06 10:45:43 +08:00
# 设置 README 为首页,并且添加标题
2024-09-06 10:54:09 +08:00
mv $HOME/wiki/quartz/content/README.md $HOME/wiki/quartz/content/index.md
sed -i '1i ---\ntitle: X·Eden\n---' $HOME/wiki/quartz/content/index.md
2024-09-06 10:45:43 +08:00
2024-01-10 16:40:48 +08:00
# 进入 Quartz 项目目录,安装依赖并构建网站
2024-09-06 10:54:09 +08:00
cd $HOME/wiki/quartz && npm ci && npx quartz build
2024-01-10 16:40:48 +08:00
# 创建 public 目录并复制构建结果到此目录
2024-09-06 10:54:09 +08:00
mkdir -p $HOME/wiki/public/ && cp -r public/* $HOME/wiki/public/
2024-01-10 16:40:48 +08:00
- name: Deploy to HTML branch of current repository (A仓库)
run: |
# 设置 Git 用户名和邮箱
2024-09-06 10:45:43 +08:00
git config --global user.name "Github Actions"
git config --global user.email "zhouzhongping@7wate.com"
2024-01-10 16:40:48 +08:00
# 在 public 目录下初始化 git 仓库
2024-09-06 10:54:09 +08:00
cd $HOME/wiki/public/ && git init && git add .
2024-01-10 16:40:48 +08:00
# 获取当天日期作为提交信息
DATE=`date '+%Y-%m-%d'`
git commit -m "Deploy HTML files - $DATE"
2024-01-10 17:33:34 +08:00
# 添加远程仓库地址
2024-09-06 10:45:43 +08:00
git remote add gitea https://${{ secrets.GITEA_PUSH_PULL_TOKEN }}@git.7wate.com/zhouzhongping/wiki.git
2024-01-10 17:33:34 +08:00
2024-01-10 16:40:48 +08:00
# 强制推送到远程的 html 分支
2024-09-06 10:45:43 +08:00
git checkout -b quartz && git push gitea quartz --force