Brain Structural Validation / Validate Markdown Structure & Links (push) Failing after 9s
7.0 KiB
7.0 KiB
type, project, tags, status
| type | project | tags | status | ||||||
|---|---|---|---|---|---|---|---|---|---|
| guide | homelab |
|
completed |
🧠 Real-Time Brain Synchronization, CI/CD & Gitea Push Mirroring
🎯 Motivation & Objectives
The Brain repository (~/Brain) is an actively edited, durable personal knowledge graph. It is accessed locally (via CLI, agents, and Obsidian) and served live to https://docs.roadtotech.me via homelab-doc2site.
Core Pipeline Invariants:
- The Curation Boundary: Raw thoughts and scratch captures stay in
inbox/(uncommitted, unvalidated, zero-friction). Once moved to their semantic home (knowledge/,projects/,records/,practice/), they join the committed graph. - Local Schema Integrity Gate: Every commit is verified locally by
scripts/validate-brain.pyvia apre-commithook to ensure valid metadata and prevent broken relative links. - Instant Zero-Delay Auto-Push: A resilient
post-commithook automatically pushes commits to the primary self-hosted Gitea forge (gitea.roadtotech.me), falling back gracefully if offline. - Automated Cloud Replication: Gitea natively push-mirrors every commit to GitHub (
github.com/kiskaadee/second-brain) immediately on receive. - Server-Side CI & Observability: Gitea Actions validates graph health on every push asynchronously without blocking editing or live rendering.
🏛️ End-to-End Architecture
┌─────────────────────────────────────────────────────────────┐
│ LOCAL WORKSTATION (~/Brain) │
│ │
│ [inbox/] (Uncommitted staging, raw capture) │
│ │ │
│ (Curate: move to knowledge/, projects/, records/) │
│ ▼ │
│ git commit │
│ │ │
│ ▼ │
│ .githooks/pre-commit ────(Invalid)────► [Abort commit] │
│ │ (Valid) │
│ ▼ │
│ Commit created │
│ │ │
│ ▼ │
│ .githooks/post-commit ───► git push origin <branch> │
└──────────────────────────────────────┬──────────────────────┘
│ (HTTPS / SSH)
▼
┌─────────────────────────────────────────────────────────────┐
│ SELF-HOSTED GITEA (gitea.roadtotech.me) │
│ │
│ Primary Forge receives new HEAD │
│ ├── 1. Push Mirror ──────────────► GitHub (Cloud Backup) │
│ ├── 2. Gitea Actions (CI) ───────► act_runner validation │
│ └── 3. doc2site Sync / Render ───► docs.roadtotech.me │
└─────────────────────────────────────────────────────────────┘
⚙️ Component Details
1. Local Git Hooks (.githooks/)
The repository maintains version-controlled hooks in .githooks/:
pre-commit: Validates repository structure, required root files, YAML frontmatter, and relative markdown links.post-commit: Automatically runsgit push origin <current-branch>with offline tolerance and detached-HEAD checks.
Installation:
Run the installer script anytime in a fresh clone:
bash scripts/install-hooks.sh
2. Gitea Actions CI Workflow (.gitea/workflows/validate.yaml)
Runs server-side verification using standard Actions syntax
3. Setting Up Gitea Actions Runner (act_runner)
To enable CI execution on gitea.roadtotech.me:
Step A: Enable Actions in Gitea app.ini
Ensure your Gitea configuration file (app.ini) includes:
[actions]
ENABLED = true
Restart Gitea if this was just enabled.
Step B: Obtain Registration Token
- In Gitea, navigate to Site Administration
\rightarrowActions\rightarrowRunners (or Repository Settings\rightarrowActions\rightarrowRunners). - Click Create new Runner and copy the registration token (
<REGISTRATION_TOKEN>).
Step C: Deploy act_runner
Option 1: Docker Compose (Homelab Host)
version: "3.8"
services:
runner:
image: gitea/act_runner:latest
container_name: gitea-act-runner
restart: always
environment:
- GITEA_INSTANCE_URL=https://gitea.roadtotech.me
- GITEA_RUNNER_REGISTRATION_TOKEN=<REGISTRATION_TOKEN>
- GITEA_RUNNER_NAME=homelab-docker-runner
- GITEA_RUNNER_LABELS=ubuntu-latest:docker://node:18-bullseye,ubuntu-22.04:docker://node:18-bullseye
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./data:/data
Option 2: Declarative NixOS Module
services.gitea-actions-runner.instances."homelab-runner" = {
enable = true;
name = "homelab-nixos-runner";
url = "https://gitea.roadtotech.me";
tokenFile = "/run/secrets/gitea-runner-token";
labels = [
"ubuntu-latest:docker://node:18-bullseye"
];
};
4. Gitea Push Mirroring (GitHub Hot Backup)
Configured under repository Settings \rightarrow Repository \rightarrow Push Mirrors:
- Remote Address:
https://github.com/kiskaadee/second-brain.git - Authorization: GitHub Username + Classic Personal Access Token with
reposcope. - Sync Trigger: "Sync when commits are pushed" enabled.
📄 Summary of Benefits
- ⚡ Zero-Friction Staging: Uncommitted raw captures in
inbox/never trigger validation failures. - 🛡️ Guaranteed Knowledge Integrity: Commits are validated before being finalized.
- 🚀 Zero-Delay Auto-Sync: Commits push instantly to Gitea and mirror to GitHub.
- 🔍 Continuous Observability: Server-side CI validates the entire knowledge graph on push.