This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy Hexo to GitHub Pages | |
on: | |
push: | |
branches: | |
- main # 触发工作流的分支 | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 # 拉取代码 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '16.x' # 设置 Node.js 版本 | |
- name: Install Dependencies | |
run: npm install # 安装依赖 | |
- name: Generate Hexo site | |
run: | | |
npx hexo clean # 清理旧文件 | |
npx hexo generate # 生成静态文件 | |
- name: Deploy to GitHub Pages | |
uses: peaceiris/actions-gh-pages@v4 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} # 使用 GitHub 提供的 Token 进行认证 | |
publish_dir: ./public # 指定发布目录 | |
publish_branch: gh-pages # 指定发布的分支 | |
force_orphan: true |