Files

38 lines
1.2 KiB
Bash

#!/bin/bash
# 在 SuiteHub 组织下创建仓库并推送代码
set -e
TOKEN="135e5d…4cb6"
ORG="SuiteHub"
REPO="yongshan-zengjian-guagou"
GITEA="https://git.mercator.cn"
echo "=== 1. 检查仓库 ==="
RESULT=$(curl -s -H "Authorization: token $TOKEN" "$GITEA/api/v1/repos/$ORG/$REPO")
if echo "$RESULT" | grep -q '"id"'; then
echo "仓库已存在"
else
echo "=== 2. 创建仓库 ==="
curl -s -X POST "$GITEA/api/v1/orgs/$ORG/repos" \
-H "Authorization: token $TOKEN" \
-H "Content-Type: application/json" \
-d "{\"name\":\"$REPO\",\"description\":\"永善县增减挂钩后备资源调查数据库生成套件\",\"private\":false,\"auto_init\":true}"
fi
echo ""
echo "=== 3. 克隆并推送代码 ==="
TMPDIR="/tmp/$REPO"
rm -rf "$TMPDIR"
git clone "https://xuhengjie:$TOKEN@$GITEA/$ORG/$REPO.git" "$TMPDIR"
cp -r /home/openclaw/.openclaw/workspace/$REPO/workflow.yaml "$TMPDIR/"
mkdir -p "$TMPDIR/scripts"
cp -r /home/openclaw/.openclaw/workspace/$REPO/scripts/*.py "$TMPDIR/scripts/"
cd "$TMPDIR"
git add -A
git commit -m "初始化 v1.0.0:增减挂钩后备资源调查数据库生成套件"
git push origin main
echo ""
echo "=== 完成 ==="
echo "仓库地址: $GITEA/$ORG/$REPO"
echo "推送状态: $?"