hexo自动化踩坑
坑一:
submodule hexo自动安装的时候并不会给设置 甚至 git add -f的时候也不会提提交 所以使用自定义模板的时候 记得先删掉模板 git commit之后再去
git submodule add https://github.com/probberechts/hexo-theme-cactus.git themes/cactus
然后在 git commit 才能够触发 github-cil的拉取子项目
坑二:
hexo -d 如果是一个私有一个公有的话 使用
1 2 3 4 5
| deploy: type: git repo: git@github.com:xxxx branch: main token: 'xxxx'
|
并不会使用token的 反而要自己拉一个私钥过去 才能正常提交
最后贴出完整的ci代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| name: Pageson: push: branches:master # default branchjobs: build: runs-on: ubuntu-latest steps:uses: actions/checkout@v4 with: token: ${{ secrets.GITHUB_TOKEN }}name: Use Node.js 18.12.0 uses: actions/setup-node@v4 with: node-version: "18.12.0"name: Cache NPM dependencies uses: actions/cache@v4 with: path: node_modules key: ${{ runner.OS }}-node-runner.OS−node−runner.OS−node−runner.OS−node−${{ hashFiles('**/package-lock.json') }} restore-keys: | ${{ runner.OS }}-node-name: Set up SSH key run: | mkdir -p ~/.ssh echo "${{ secrets.DEPLOY_KEY }}" > ~/.ssh/id_rsa chmod 600 ~/.ssh/id_rsa ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts env: DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}name: Install Dependencies run: npm installname: Initialize and Update Submodules run: | git submodule update --init --recursive ./themes/cactusname: Install hexo-blog-encrypt run: npm install hexo-blog-encrypt --savename: Install Dependencies run: npm install hexoname: Install Hexo run: npm install -g hexo-cliname: Run Hexo Commands run: hexo gname: Run Hexo Commands run: hexo d
|
上述代码要先把 node_modules git add -f进去才有用