#!/bin/bash set -e GITEA_URL="http://localhost:3000" REPO_NAME="momentry_studio" BRANCH="main" echo "=========================================" echo " Momentry Studio Gitea CI/CD" echo "=========================================" # 1. 初始化 Git 倉庫 echo "" echo "📋 Step 1: 初始化 Git 倉庫..." if [ ! -d ".git" ]; then git init git add . git commit -m "Initial commit: Momentry Studio v0.1.0" fi echo "✅ Git 倉庫已初始化" # 2. 建立 Gitea 倉庫 echo "" echo "🏗️ Step 2: 建立 Gitea 倉庫..." # 檢查倉庫是否已存在 if ! curl -s "$GITEA_URL/api/v1/repos/$USER/$REPO_NAME" | grep -q "not found"; then echo "倉庫已存在,跳過建立" else curl -s -X POST "$GITEA_URL/api/v1/user/repos" \ -H "Content-Type: application/json" \ -d "{\"name\":\"$REPO_NAME\",\"private\":false,\"auto_init\":false}" echo "✅ Gitea 倉庫已建立" fi # 3. 推送程式碼 echo "" echo "📤 Step 3: 推送程式碼到 Gitea..." git remote remove gitea 2>/dev/null || true git remote add gitea "$GITEA_URL/admin/$REPO_NAME.git" 2>/dev/null || true git push -u gitea $BRANCH -f 2>/dev/null || echo "推送失敗(需要設定 Gitea token)" echo "✅ 程式碼已推送" # 4. 執行 CI/CD echo "" echo "🔨 Step 4: 執行 CI/CD..." ./ci-cd.sh echo "" echo "=========================================" echo " ✅ Gitea CI/CD 完成" echo "========================================="