Skip to content

Commit 01cadb2

Browse files
authored
Release: static blog scaffold + auto-publish CI (review 88/100)
Release: static blog scaffold + auto-publish CI
2 parents 906dc00 + fa81d48 commit 01cadb2

10 files changed

Lines changed: 518 additions & 89 deletions

File tree

.codex/setup.sh

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,10 @@ set -euo pipefail
1010

1111
echo "[codex-setup] OpenBlog: preparing environment"
1212

13-
# --- Node.js / static-site generator (uncomment once a package.json exists) ---
14-
# if [ -f package.json ]; then
15-
# echo "[codex-setup] installing npm dependencies"
16-
# npm ci || npm install
17-
# fi
13+
# --- Node.js / static-site generator ------------------------------------------
14+
if [ -f package.json ]; then
15+
echo "[codex-setup] installing npm dependencies"
16+
npm ci || npm install
17+
fi
1818

19-
# --- Python (uncomment if a Python-based generator is used) -------------------
20-
# if [ -f requirements.txt ]; then
21-
# echo "[codex-setup] installing pip dependencies"
22-
# pip install -r requirements.txt
23-
# fi
24-
25-
echo "[codex-setup] done (no toolchain configured yet)"
19+
echo "[codex-setup] done"

.github/workflows/blank.yml

Lines changed: 0 additions & 36 deletions
This file was deleted.

.github/workflows/publish.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Generate & Publish
2+
3+
# Builds the static site from posts/ and publishes it to GitHub Pages.
4+
#
5+
# Triggers:
6+
# - daily on a schedule (so AI-generated posts go live automatically)
7+
# - on push to main (the production branch)
8+
# - manually via the Actions tab
9+
#
10+
# Note: develop is the integration branch; publishing happens from main.
11+
# Merge develop -> main to release.
12+
13+
on:
14+
schedule:
15+
# 23:17 UTC daily (~07:17 Asia/Shanghai). Off the :00 mark on purpose.
16+
- cron: "17 23 * * *"
17+
push:
18+
branches: ["main"]
19+
workflow_dispatch:
20+
21+
permissions:
22+
contents: read
23+
pages: write
24+
id-token: write
25+
26+
# Allow only one concurrent deployment.
27+
concurrency:
28+
group: "pages"
29+
cancel-in-progress: true
30+
31+
jobs:
32+
build:
33+
runs-on: ubuntu-latest
34+
steps:
35+
- uses: actions/checkout@v4
36+
37+
- uses: actions/setup-node@v4
38+
with:
39+
node-version: "20"
40+
cache: "npm"
41+
42+
- name: Install dependencies
43+
run: npm ci
44+
45+
- name: Build site
46+
run: npm run build
47+
48+
- name: Upload Pages artifact
49+
uses: actions/upload-pages-artifact@v3
50+
with:
51+
path: public
52+
53+
deploy:
54+
needs: build
55+
runs-on: ubuntu-latest
56+
environment:
57+
name: github-pages
58+
url: ${{ steps.deployment.outputs.page_url }}
59+
steps:
60+
- name: Deploy to GitHub Pages
61+
id: deployment
62+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Dependencies
2+
node_modules/
3+
4+
# Build output (regenerated by scripts/build.mjs)
5+
public/
6+
7+
# Logs / OS cruft
8+
*.log
9+
.DS_Store

AGENTS.md

Lines changed: 57 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,61 +4,84 @@ Guidance for AI coding agents (OpenAI Codex and similar) working in the **OpenBl
44

55
## What this repo is
66

7-
OpenBlog is a personal blog project. The repository is currently an early
8-
scaffold — at the time of writing it contains only a `README.md` and a starter
9-
GitHub Actions workflow (`.github/workflows/blank.yml`). There is **no
10-
application code, build system, or test suite yet**. Treat the structure below
11-
as the intended target; create files as needed when implementing a task.
7+
OpenBlog is a personal blog system positioned as an **AI-driven, auto-generate &
8+
auto-publish blog**: daily thoughts become your memory, daily posts become your
9+
IP. See [README.md](README.md) for the full positioning.
10+
11+
The repo now ships a working **static-site generator**: Markdown posts in
12+
`posts/` are rendered to a static site in `public/` and published to GitHub
13+
Pages by CI.
1214

1315
## Repository layout
1416

1517
```
1618
.
1719
├── AGENTS.md # this file
18-
├── README.md
20+
├── README.md # positioning + usage
21+
├── package.json # scripts: build, serve
22+
├── posts/ # Markdown articles (the content source)
23+
│ └── *.md # front matter: title, date, tags, summary
24+
├── scripts/
25+
│ └── build.mjs # static-site generator (Markdown -> public/)
26+
├── public/ # build output (git-ignored, regenerated)
1927
└── .github/
2028
└── workflows/
21-
└── blank.yml # placeholder CI (echoes hello world)
29+
└── publish.yml # scheduled generate + publish to Pages
2230
```
2331

24-
When you add real code, prefer a conventional static-site / blog layout
25-
(e.g. `src/`, `content/` or `posts/` for Markdown articles, `public/` or
26-
`dist/` for build output). Document any structure you introduce back in this
27-
file and the `README.md`.
28-
29-
## Branches
32+
## Branch policy — IMPORTANT
3033

31-
- `main` — default / production branch.
32-
- `develop` — integration branch.
34+
- **`develop`** — integration branch. **This is the default branch for all work
35+
and pushes.** Commit here and `git push origin develop`.
36+
- **`main`** — production / published branch. The publish workflow deploys from
37+
`main`. Only merge `develop -> main` when explicitly releasing/publishing.
3338

34-
Open pull requests against `main` unless the task says otherwise. Never force-push
35-
shared branches.
39+
**Default to `develop`.** Do NOT push or open PRs against `main` unless the task
40+
explicitly says to release/publish. Never force-push shared branches.
3641

3742
## Build, run, and test
3843

39-
There is no build or test tooling configured yet. **Do not invent commands that
40-
do not exist.** If a task requires building or testing:
44+
Toolchain: Node.js (ESM), deps `marked` + `gray-matter`.
45+
46+
```bash
47+
npm ci # install (CI) — or npm install locally
48+
npm run build # render posts/ -> public/
49+
npm run serve # build, then serve public/ at http://localhost:8080
50+
```
51+
52+
Validation for a change: `npm run build` succeeds and produces
53+
`public/index.html` plus one `public/posts/<slug>.html` per post. Verify the
54+
build runs before claiming it works.
4155

42-
1. Choose a stack appropriate to a blog (e.g. a static-site generator), add its
43-
manifest (`package.json`, etc.), and wire real `build`/`test` scripts.
44-
2. Update this section and the CI workflow with the actual commands you added.
45-
3. Verify commands run locally before claiming they work.
56+
## Authoring posts
57+
58+
Add a `.md` file under `posts/` (filename becomes the URL slug). Front matter:
59+
60+
```markdown
61+
---
62+
title: My thought
63+
date: 2026-06-11
64+
tags: [memory, ai]
65+
summary: One-line teaser shown on the index.
66+
---
67+
68+
# My thought
69+
...
70+
```
4671

47-
Until then, validation means: the repo still clones, Markdown/HTML renders, and
48-
the CI workflow stays green.
72+
All fields are optional — missing title falls back to the first heading or the
73+
filename; missing date falls back to file mtime.
4974

5075
## Conventions
5176

5277
- Keep changes focused and minimal; match the style of surrounding files.
53-
- Blog content should be authored in Markdown.
54-
- Commit messages: short imperative subject line; explain the "why" in the body
55-
when non-obvious.
56-
- Do not commit secrets, build artifacts, or large binaries.
78+
- Blog content is authored in Markdown.
79+
- Don't commit `node_modules/` or `public/` (both git-ignored).
80+
- Commit messages: short imperative subject; explain the "why" when non-obvious.
5781

5882
## For the Codex cloud agent
5983

60-
- Read this file first to understand scope before making changes.
61-
- An optional environment setup script lives at `.codex/setup.sh` — run it to
62-
prepare a working environment. It is a no-op until a real toolchain is added.
63-
- Make the smallest change that satisfies the task, open a PR against `main`,
64-
and describe what you did and how you verified it.
84+
- Read this file first; respect the **develop-default** branch policy above.
85+
- Environment setup script: [.codex/setup.sh](.codex/setup.sh) (runs `npm ci`).
86+
- Make the smallest change that satisfies the task, push to `develop`, and
87+
describe what you did and how you verified it (`npm run build`).

README.md

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,27 +60,59 @@ OpenBlog 用 AI Agent 把这条链路自动化:
6060

6161
## 项目状态
6262

63-
> ⚠️ **早期阶段(Scaffold)**
63+
> 🚧 **早期可用(Early / MVP)**
6464
>
65-
> 当前仓库处于初始搭建阶段,尚未包含完整的应用代码与生成/发布流水线。
66-
> 上面描述的是项目的**目标定位与设计蓝图**,功能正在逐步落地。
65+
> 已具备一条可运行的静态站点流水线:`posts/` 里的 Markdown 文章会被生成器渲染成站点,并由 CI 定时构建、自动发布到 GitHub Pages。AI 自动撰写文章的环节正在逐步接入。
6766
6867
### 路线图(Roadmap)
6968

69+
- [x] 静态站点生成器(Markdown → HTML)
70+
- [x] 自动构建与发布(GitHub Pages,定时 + 触发)
7071
- [ ] 记忆采集与结构化存储
71-
- [ ] AI 文章生成流水线
72-
- [ ] 自动构建与发布
73-
- [ ] 定时 / 触发式自动运行
72+
- [ ] AI 文章生成流水线(由记忆自动撰写)
7473
- [ ] 站点主题与个人化配置
7574

7675
## 快速开始
7776

7877
```bash
7978
git clone https://github.com/xiami303/OpenBlog.git
8079
cd OpenBlog
80+
npm install # 安装依赖
81+
npm run build # 渲染 posts/ → public/
82+
npm run serve # 构建并本地预览 http://localhost:8080
8183
```
8284

83-
> 构建与运行命令将随功能落地补充。当前仓库尚无构建工具链 —— 详见 [AGENTS.md](AGENTS.md)
85+
### 写一篇文章
86+
87+
`posts/` 下新建一个 `.md` 文件(文件名即文章 URL slug),开头写好 front matter:
88+
89+
```markdown
90+
---
91+
title: 我的想法
92+
date: 2026-06-11
93+
tags: [memory, ai]
94+
summary: 显示在首页的一句话简介。
95+
---
96+
97+
# 我的想法
98+
...
99+
```
100+
101+
所有字段都可省略 —— 没有 title 就用第一个标题或文件名,没有 date 就用文件修改时间。运行 `npm run build` 后,文章就会出现在站点上。
102+
103+
## 目录结构
104+
105+
```
106+
posts/ # Markdown 文章(内容源)
107+
scripts/build.mjs # 静态站点生成器
108+
public/ # 构建产物(自动生成,已 gitignore)
109+
.github/workflows/ # 定时生成 + 自动发布到 Pages
110+
```
111+
112+
## 分支规则
113+
114+
- **`develop`** —— 集成分支,**日常开发与提交的默认分支**
115+
- **`main`** —— 生产 / 已发布分支,CI 从这里部署到 Pages。仅在发布时把 `develop` 合并到 `main`
84116

85117
## 参与开发
86118

0 commit comments

Comments
 (0)