静态博客搭建记录2

笔记主要包含实现自动部署的工作流。

参考

结合了第二、三个博文中的 workflow 文件,最终实现自动化部署。Obsidian 一键上传用到了 envelope 。

我的 workflow 文件

 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
name: Generate Hexo Blog

on:
  push:
    branches:
      - main # default branch

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          submodules: true
      - name: Use Node.js 16.x   #配置node环境
        uses: actions/setup-node@v2
        with:
          node-version: '20.11.1'
      - name: Setup Hexo environment
        run: |
         npm install -g hexo-cli
         npm ci
      - name: Generate pages
        run: |
          hexo generate
          ls -R public/
      # - name: Cache NPM dependencies  
      #   uses: actions/cache@v2
      #   with:
      #     path: node_modules
      #     key: ${{ runner.OS }}-npm-cache
      #     restore-keys: |
      #       ${{ runner.OS }}-npm-cache
      # - name: Install Dependencies
      #   run: npm install
      # - name: Build
      #   run: npm run build
      # - name: Upload Pages artifact
      #   uses: actions/upload-pages-artifact@v2
      #   with:
      #     path: ./public
      
  # deploy:
  #   needs: build
  #   permissions:
  #     pages: write
  #     id-token: write
  #   environment:
  #     name: github-pages
  #     url: ${{ steps.deployment.outputs.page_url }}
  #   runs-on: ubuntu-latest
  #   steps:
  #     - name: Deploy to GitHub Pages
  #       id: deployment
  #       uses: actions/deploy-pages@v2
      - name: Deploy
        uses: JamesIves/github-pages-deploy-action@releases/v3
        with:
          REPOSITORY_NAME: yohakuo/yohakuo.github.io
          BRANCH: html
          FOLDER: public

主题

我当时配置这个主题出现了一点问题,最后是把它作为子模块工作流才能运行成<submodules: true>

问题解决

You have unmerged paths.

  • 查看下暂存区修改后的文件状态。
1
git status
  • 来到标红的文件进行修改,再次 push **MERGING** 就没有了

git push -u origin –> fatal: unable to access

  • 远程仓库和本地不一致,比如远程有的文件本地没有
  • 查询并取消代理
1
2
3
git config --global http.proxy
 
git config --global --unset http.proxy
  • 修改dns
1
git pull origin <name>