以下是 hexo 配置文件_config.yml 部署配置项:
deploy:
  type: git
  repo: git@github.com:xx/xx.github.io.git
  branch: main
以下是.gitignore 文件内容:
.DS_Store
Thumbs.db
db.json
*.log
node_modules/
public/
.deploy*/
以下是 Github Actions 配置文件:
name: CI
on:
  push:
    branches:
      - main
jobs:
  build:
    runs-on: ubuntu-latest # 在最新版的 Ubuntu 系统下运行
    
    steps:
    - name: Checkout # 将仓库内 master 分支的内容下载到工作目录
      uses: actions/checkout@v1 # 脚本来自 https://github.com/actions/checkout
      
    - name: Use Node.js 10.x # 配置 Node 环境
      uses: actions/setup-node@v1 # 配置脚本来自 https://github.com/actions/setup-node
      with:
        node-version: "10.x"
    
    - name: Setup Hexo env
      env:
        ACTION_DEPLOY_KEY: ${{ secrets.HEXO_DEPLOY_PRI }}
      run: |
        # set up private key for deploy
        mkdir -p ~/.ssh/
        echo "$ACTION_DEPLOY_KEY" | tr -d '\r' > ~/.ssh/id_rsa # 配置秘钥
        chmod 600 ~/.ssh/id_rsa
        ssh-keyscan github.com >> ~/.ssh/known_hosts
        
        # set git infomation
        git config --global user.name 'xx'
        git config --global user.email 'xx@qq.com'
        # install dependencies
        npm install -g hexo-cli
        npm install
  
    - name: Deploy
      run: |
        hexo clean
        hexo generate
        hexo deploy # 执行部署程序
Github Pages 主分支为 main 分支,也只有这一个分支。但是 push Hexo 到 Github,自动部署后推送到 xx.github.io 仓库的 html 内容却为空,本地 hexo server 后预览正常。
请勿需要如何改进下,可以实现正确的自动部署?
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.