静态博客搭建指南2.0

参考

结合了第二、三个博文中的 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

基本操作

  • 切换分支
1
git checkout main
  • 从远程仓库拉取最新的更改并合并到本地仓库
1
git pull origin main
  • 保存更改并推送到 GitHub:
1
git add .  
1
git commit -m "main workflow configure"  
1
git commit -m "Vault backup"
1
git push -u origin main
  • 暂存更改(将它们暂存起来,然后在合并分支后再恢复)
1
git stash
1
git stash apply
  • 删除这些更改
1
git stash drop
  • 删除远程分支
1
git push origin --delete
  • 关联分支
1
git branch -u origin/main
  • 文件和文件夹的删除
1
git rm <name>
1
git rm -r <name>

主题

我记得当时配置这个主题出现了一点问题,最后是把它作为子模块工作流才能运行成<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>

静态博客搭建指南2.0
https://yohakuo.github.io/2024/03/22/静态博客搭建指南2.0/
作者
liuliu
发布于
2024年3月23日
许可协议