Skip to content

auto published by siyuan-plugin-publisher #10

auto published by siyuan-plugin-publisher

auto published by siyuan-plugin-publisher #10

Workflow file for this run

name: Deploy Hexo Blog to GitHub Pages
on:
push:
branches: [main] # 只监听 main 分支的推送
workflow_dispatch: # 允许手动触发
jobs:
build-and-deploy:
timeout-minutes: 30
runs-on: ubuntu-latest
permissions:
contents: write # 授予写入权限用于推送到 gh-pages
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # 获取完整历史记录
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20' # 使用 Node.js 20 LTS
cache: 'npm'
- name: Install dependencies
run: |
npm ci
npm install -g hexo-cli
echo "✓ Dependencies installed"
- name: Build Hexo site
run: |
hexo clean
hexo generate
echo "✓ Hexo site generated"
- name: Deploy to gh-pages branch
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
publish_branch: gh-pages
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
commit_message: 'Deploy: ${{ github.event.head_commit.message }}'
- name: Upload build artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: blog-public
path: public/
retention-days: 7