This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

stigmergic / container / sync.ts
1.8 kB 54 lines
1// ─── Sync: pull vault + carry into container ────────────────────── 2// 3// vault: ob sync (Obsidian Sync) 4// carry: git pull from GitHub private repo 5 6import { execSync } from "child_process"; 7 8const VAULT_PATH = process.env.VAULT_PATH || "/data/vault"; 9const CARRY_PATH = process.env.CARRY_PATH || "/data/carry"; 10const CARRY_REMOTE = process.env.CARRY_REMOTE || ""; 11const CARRY_BRANCH = process.env.CARRY_BRANCH || "main"; 12 13export async function syncVault(): Promise<void> { 14 try { 15 execSync(`ob sync ${VAULT_PATH}`, { stdio: "pipe", timeout: 60000 }); 16 console.log("[sync] vault synced via ob"); 17 } catch (e: any) { 18 console.error("[sync] vault sync failed:", e.message); 19 } 20} 21 22export async function syncCarry(): Promise<void> { 23 if (!CARRY_REMOTE) { 24 console.error("[sync] CARRY_REMOTE not set, skipping carry sync"); 25 return; 26 } 27 28 try { 29 // If not cloned yet, clone; otherwise pull 30 try { 31 execSync(`git -C ${CARRY_PATH} rev-parse --git-dir`, { stdio: "pipe" }); 32 execSync(`git -C ${CARRY_PATH} pull origin ${CARRY_BRANCH}`, { 33 stdio: "pipe", 34 timeout: 30000, 35 env: { ...process.env, GIT_TERMINAL_PROMPT: "0" }, 36 }); 37 console.log("[sync] carry pulled via git"); 38 } catch { 39 // Not a git repo — clone 40 execSync(`git clone --branch ${CARRY_BRANCH} --single-branch ${CARRY_REMOTE} ${CARRY_PATH}`, { 41 stdio: "pipe", 42 timeout: 60000, 43 env: { ...process.env, GIT_TERMINAL_PROMPT: "0" }, 44 }); 45 console.log("[sync] carry cloned via git"); 46 } 47 } catch (e: any) { 48 console.error("[sync] carry sync failed:", e.message); 49 } 50} 51 52export async function syncAll(): Promise<void> { 53 await Promise.all([syncVault(), syncCarry()]); 54}