20
scripts/README-GitHub同步.md
Normal file
20
scripts/README-GitHub同步.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# 卡若AI · GitHub 同步说明
|
||||
|
||||
- **本地路径**:`/Users/karuo/Documents/个人/卡若AI`
|
||||
- **GitHub 仓库**:https://github.com/fnvtk/karuo-ai
|
||||
|
||||
## 手动同步
|
||||
```bash
|
||||
cd "/Users/karuo/Documents/个人/卡若AI"
|
||||
./scripts/push-to-github.sh
|
||||
```
|
||||
|
||||
## 定时任务
|
||||
已安装:每 4 小时自动执行一次同步(有变更才提交并推送)。
|
||||
- 卸载:`launchctl unload ~/Library/LaunchAgents/com.karuo.ai.push-github.plist`
|
||||
|
||||
## Token
|
||||
上传使用的 GitHub Token 由卡路亚提供;若更换账号或 Token,请更新 remote:
|
||||
```bash
|
||||
git remote set-url origin https://<新TOKEN>@github.com/fnvtk/karuo-ai.git
|
||||
```
|
||||
23
scripts/com.karuo.ai.push-github.plist
Normal file
23
scripts/com.karuo.ai.push-github.plist
Normal file
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>Label</key>
|
||||
<string>com.karuo.ai.push-github</string>
|
||||
<key>ProgramArguments</key>
|
||||
<array>
|
||||
<string>/bin/bash</string>
|
||||
<string>/Users/karuo/Documents/个人/卡若AI/scripts/push-to-github.sh</string>
|
||||
</array>
|
||||
<key>StartInterval</key>
|
||||
<integer>14400</integer>
|
||||
<key>WorkingDirectory</key>
|
||||
<string>/Users/karuo/Documents/个人/卡若AI</string>
|
||||
<key>StandardOutPath</key>
|
||||
<string>/tmp/karuo-ai-push-github.log</string>
|
||||
<key>StandardErrorPath</key>
|
||||
<string>/tmp/karuo-ai-push-github.err</string>
|
||||
<key>RunAtLoad</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</plist>
|
||||
23
scripts/push-to-github.sh
Executable file
23
scripts/push-to-github.sh
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
# 卡若AI · 本地 → GitHub 同步(路径:个人/卡若AI)
|
||||
# 用法:./scripts/push-to-github.sh [提交说明]
|
||||
|
||||
set -e
|
||||
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
cd "$REPO_ROOT"
|
||||
|
||||
if ! git remote get-url origin &>/dev/null; then
|
||||
echo "未配置 origin。请执行: git remote add origin <仓库URL>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if git diff --quiet && git diff --cached --quiet && [[ -z $(git status -s) ]]; then
|
||||
echo "[$(date '+%Y-%m-%d %H:%M')] 无变更,跳过推送。"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
git add -A
|
||||
msg="${1:-同步卡若AI:$(date '+%Y-%m-%d %H:%M')}"
|
||||
git commit -m "$msg" || true
|
||||
git push origin HEAD
|
||||
echo "[$(date '+%Y-%m-%d %H:%M')] 已推送到 GitHub。"
|
||||
Reference in New Issue
Block a user