344 字
2 分钟
Hexo Blog方案
- 拆分Posts路径到单独Branch,Obsidian挂Posts Branch,本地Markdown只有文章部分,写完直接推送触发编译
- 本地Gitea Action编译->只推送静态资源到Github
- Vercel托管,可以享受较快的国内的访问速度,感谢下面项目提供优质cname解析 https://github.com/xingpingcn/enhanced-FaaS-in-China
Gitea Workflow
name: Build Hexo Blog
on: push: branches: - posts # This workflow will be triggered when pushing to posts branch workflow_dispatch: # Allow manual trigger
jobs: build: runs-on: ubuntu-latest
steps: - name: Checkout repository uses: actions/checkout@v4 with: fetch-depth: 0 # Fetch all history for all branches
- name: Setup Node.js uses: actions/setup-node@v4 with: node-version: '20'
# - name: Clean posts directory # run: | # rm -rf source/*
- name: Copy posts run: | # 获取posts分支 git fetch origin posts:posts # 创建临时目录 mkdir -p temp_posts cd temp_posts # 检出posts分支的内容 git --git-dir=../.git --work-tree=. checkout posts -- . # 复制所有文件到source/ cp -r * ../source/ cd .. # 清理临时目录 rm -rf temp_posts
- name: Install dependencies run: npm install
- name: Build Hexo site run: npx hexo generate
- name: Push to GitHub env: HLPJTOKEN: ${{ secrets.HLPJTOKEN }} ACTOR: ${{ vars.GITHUBACTOR }} REPOSITORY: ${{ vars.GITHUBREPOSITORY }} run: | # 克隆目标仓库 git clone "https://${ACTOR}:${HLPJTOKEN}@github.com/${REPOSITORY}.git" temp_deploy cd temp_deploy
# 清空仓库内容(保留.git目录) find . -mindepth 1 -maxdepth 1 ! -name '.git' -exec rm -rf {} +
# 复制新生成的文件 cp -r ../public/* .
# 配置git git config user.name "${ACTOR}" git config user.email "${ACTOR}@users.noreply.github.com"
# 添加所有文件并提交 git add -A git commit -m "Build: Update site content"
# 推送到main分支 git push origin HEAD:main