www.colben.cn/README.md
2023-04-16 22:47:25 +08:00

71 lines
1.6 KiB
Markdown

# 个人博客
## 介绍
- 该博客由 [hugo](https://www.gohugo.org/) 生成
- 使用 [even](https://github.com/olOwOlo/hugo-theme-even/blob/master/README-zh.md) 主题
## 编辑
- 获取博客 md 文件
```bash
git clone https://git.colben.cn/colben/www.colben.cn.git
```
- 获取主题
```bash
cd www.colben.cn
git clone https://github.com/olOwOlo/hugo-theme-even.git themes/even
```
- 本地编译,生成页面,仅用于本地调试,不会提交
```bash
hugo --baseURL="https://www.colben.cn/"
```
- 提交和推送
```bash
git commit -a -m 'update info'
git push
```
## 挂载 hugo 和 nginx 前端目录
- 下载 [hugo_extended_0.106.0](https://github.com/gohugoio/hugo/releases/download/v0.106.0/hugo_extended_0.106.0_linux-amd64.tar.gz)
- 解压获取可执行二进制文件 hugo
- 挂载 hugo 到 gitea 容器中
```yaml
- type: bind
source: ./gitea/hugo
target: /usr/bin/hugo
```
- 挂载 nginx 前端目录到 gitea 容器中
```yaml
- type: bind
source: ./nginx/html
target: /html
```
## 发布
- 配置本仓库的 post-receive 钩子,内容如下
```bash
set -euo pipefail
exec &> /opt/gitea/log/post-receive.log
date +'[%F %T] Update www.colben.cn ...'
cd /html/www.colben.cn
env -i git pull origin master
hugo
```
- 克隆本仓库的前端目录
```bash
docker exec -ti gitea /bin/bash # 进入 gitea 容器
chown gitea.gitea /html
su - gitea
cd /html
git clone https://git.colben.cn/colben/www.colben.cn.git
cd www.colben.cn
hugo
exit # 退出容器
```