34 lines
1.5 KiB
Bash
Executable File
34 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
||
# Workspace自动备份脚本,基于vala_git_workspace_backup.vala规范
|
||
WORKSPACE_DIR="/root/.openclaw/workspace-xiaobian"
|
||
cd "$WORKSPACE_DIR" || exit 1
|
||
|
||
# 配置远程仓库地址
|
||
git remote set-url origin https://ai_member_only:ai%40makee260301%23@git.valavala.com/ai_member_only/ai_member_xiaobian.git || true
|
||
|
||
# 拉取最新代码
|
||
git pull origin master || true
|
||
# 提交所有变更
|
||
git add .
|
||
git commit -m "auto backup $(date +'%Y-%m-%d %H:%M:%S')" || true
|
||
# 推送到远程仓库
|
||
git push origin master || true
|
||
|
||
# 备份成功后发送通知给李若松
|
||
if [ $? -eq 0 ] || [ $? -eq 1 ]; then
|
||
# 获取飞书token
|
||
APP_ID=$(jq -r '.apps[0].appId' /root/.openclaw/credentials/xiaobian/config.json)
|
||
APP_SECRET=$(jq -r '.apps[0].appSecret' /root/.openclaw/credentials/xiaobian/config.json)
|
||
FEISHU_TOKEN=$(curl -s -X POST "https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal" \
|
||
-H "Content-Type: application/json" \
|
||
-d "{\"app_id\":\"$APP_ID\",\"app_secret\":\"$APP_SECRET\"}" | jq -r '.tenant_access_token')
|
||
|
||
# 发送消息
|
||
curl -s -X POST "https://open.feishu.cn/open-apis/im/v1/messages?receive_id_type=user_id" \
|
||
-H "Authorization: Bearer $FEISHU_TOKEN" \
|
||
-H "Content-Type: application/json" \
|
||
-d '{"receive_id": "4aagb443", "msg_type": "text", "content": "{\"text\":\"✅ 小编Workspace自动备份成功,备份时间:'$(date +'%Y-%m-%d %H:%M:%S')'\"}"}' >> "$WORKSPACE_DIR/logs/backup.log" 2>&1
|
||
fi
|
||
|
||
echo "✅ 备份完成:$(date)"
|