Files
opencode-skill/skills/thai-frontend-dev/AUTO_DEPLOY_IMPLEMENTATION.md
Kunthawat Greethong 7edf5bc4d0 feat: Import 35+ skills, merge duplicates, add openclaw installer
Major updates:
- Added 35+ new skills from awesome-opencode-skills and antigravity repos
- Merged SEO skills into seo-master
- Merged architecture skills into architecture
- Merged security skills into security-auditor and security-coder
- Merged testing skills into testing-master and testing-patterns
- Merged pentesting skills into pentesting
- Renamed website-creator to thai-frontend-dev
- Replaced skill-creator with github version
- Removed Chutes references (use MiniMax API instead)
- Added install-openclaw-skills.sh for cross-platform installation
- Updated .env.example with MiniMax API credentials
2026-03-26 11:37:39 +07:00

12 KiB

🚀 Auto-Deploy Implementation Plan

Status: Phase 1 Complete - Ready for Full Implementation
Date: 2026-03-08


📋 REQUIREMENTS SUMMARY

From User

  1. Gitea Integration - Auto-create/update repos on git.moreminimore.com
  2. Easypanel Auth - Username/password (auto-generate token)
  3. Unified .env - Single file for all skills
  4. Install Script - Auto-sync all skills to OpenCode global
  5. Auto-Detection - New vs existing projects

🏗️ ARCHITECTURE

Skills Structure

opencode-skill/
├── .env.example              # Unified template (ALL skills)
├── scripts/
│   └── install-skills.sh     # Updated for unified .env
└── skills/
    ├── gitea-sync/           # NEW - Gitea automation
    │   ├── SKILL.md
    │   └── scripts/
    │       ├── sync.py       # Main script
    │       └── .env.example  # (uses unified .env)
    │
    ├── easypanel-deploy/     # UPDATED - Python script added
    │   ├── SKILL.md
    │   └── scripts/
    │       ├── deploy.py     # NEW - Auto-deploy with username/pass
    │       └── .env.example  # (uses unified .env)
    │
    └── website-creator/      # UPDATED - Auto-deploy integration
        ├── SKILL.md
        └── scripts/
            ├── create_astro_website.py  # Updated
            └── .env.example             # (uses unified .env)

Unified .env File

Location during development: /Users/kunthawatgreethong/Gitea/opencode-skill/.env

Location after install: ~/.config/opencode/.env

Contents:

# ===========================================
# UNIFIED OPENCODE SKILLS CONFIGURATION
# ===========================================

# Gitea Configuration
GITEA_URL=https://git.moreminimore.com
GITEA_API_TOKEN=your-gitea-api-token
GITEA_USERNAME=your-username

# Easypanel Configuration
EASYPANEL_URL=http://110.164.146.47:3000
EASYPANEL_USERNAME=your-username
EASYPANEL_PASSWORD=your-password
EASYPANEL_DEFAULT_PROJECT=default

# Umami Analytics (optional)
UMAMI_DOMAIN=analytics.example.com

# Admin (for all websites)
ADMIN_PASSWORD=your-secure-password

🎯 IMPLEMENTATION PHASES

Phase 1: easypanel-deploy COMPLETE

Created:

  • scripts/deploy.py - Full Python implementation
  • scripts/.env.example - Credentials template
  • scripts/requirements.txt - Dependencies

Features:

  • Username/password authentication
  • Auto-generates API token
  • Follows exact workflow from SKILL.md
  • Creates project → service → connects Git → deploys
  • Checks deployment status

Usage:

cd skills/easypanel-deploy
python3 scripts/deploy.py \
  --project my-website \
  --service my-website-service \
  --git-url https://git.moreminimore.com/user/my-website.git

Phase 2: gitea-sync NEXT

To Create:

  • New skill: gitea-sync
  • Python script for Gitea API
  • Auto-detect new/existing repos
  • Push code automatically

Features:

# sync.py - Planned functionality

def check_repo_exists(username, repo_name):
    """Check if repository exists on Gitea."""
    response = requests.get(
        f"{GITEA_URL}/api/v1/repos/{username}/{repo_name}",
        headers={"Authorization": f"token {GITEA_API_TOKEN}"}
    )
    return response.status_code == 200

def create_repo(repo_name, description=""):
    """Create new repository."""
    if check_repo_exists(GITEA_USERNAME, repo_name):
        print(f"✅ Repository exists: {repo_name}")
        return update_repo(repo_name)
    else:
        print(f"📦 Creating repository: {repo_name}")
        response = requests.post(
            f"{GITEA_URL}/api/v1/user/repos",
            headers={"Authorization": f"token {GITEA_API_TOKEN}"},
            json={
                "name": repo_name,
                "description": description,
                "private": False,
                "auto_init": True
            }
        )
        return response.json()

def push_code(repo_path, git_url):
    """Push code to Gitea repository."""
    subprocess.run(["git", "init"], cwd=repo_path)
    subprocess.run(["git", "add", "."], cwd=repo_path)
    subprocess.run(["git", "commit", "-m", "Initial commit"], cwd=repo_path)
    subprocess.run(["git", "remote", "add", "origin", git_url], cwd=repo_path)
    subprocess.run(["git", "push", "-u", "origin", "main"], cwd=repo_path)

Usage:

python3 scripts/sync.py \
  --repo my-website \
  --path ./my-website \
  --description "My PDPA-compliant website"

Phase 3: website-creator Integration PENDING

Update: create_astro_website.py

Add auto-deploy workflow:

def auto_deploy(website_path, website_name, args):
    """Complete auto-deploy workflow."""
    
    # Step 1: Sync to Gitea
    print("📦 Syncing to Gitea...")
    git_url = f"https://git.moreminimore.com/{GITEA_USERNAME}/{website_name}.git"
    
    subprocess.run([
        "python3",
        f"{SKILLS_DIR}/gitea-sync/scripts/sync.py",
        "--repo", website_name,
        "--path", str(website_path),
        "--description", f"Auto-generated website: {website_name}"
    ])
    
    # Step 2: Deploy to Easypanel
    print("🚀 Deploying to Easypanel...")
    subprocess.run([
        "python3",
        f"{SKILLS_DIR}/easypanel-deploy/scripts/deploy.py",
        "--project", website_name,
        "--service", f"{website_name}-service",
        "--git-url", git_url,
        "--branch", "main",
        "--port", "80"
    ])
    
    # Step 3: Return deployment URL
    print("✅ Deployment complete!")
    print(f"🌐 URL: https://{website_name}.easypanel.app")

Integration point: At end of main() function, after website generation.


Phase 4: install-skills.sh Update PENDING

Current behavior:

  • Prompts for each skill's .env separately
  • Creates .env files in each skill directory

New behavior:

  • Single unified .env at repo root
  • Copies to ~/.config/opencode/.env
  • All skills read from same file

Updated workflow:

#!/bin/bash

# 1. Check for unified .env.example
if [ -f "${REPO_ROOT}/.env.example" ]; then
    # Prompt for unified .env
    create_unified_env
fi

# 2. Install skills
for skill in $SKILLS; do
    cp -r "${SKILLS_DIR}/${skill}" "$TARGET"
    
    # Create skill-specific .env that sources unified .env
    cat > "${TARGET}/${skill}/scripts/.env" << EOF
# Auto-generated - sources unified .env
# Edit ${HOME}/.config/opencode/.env instead
EOF
done

# 3. Copy unified .env to global location
cp "${REPO_ROOT}/.env" "${HOME}/.config/opencode/.env"
chmod 600 "${HOME}/.config/opencode/.env"

Phase 5: Unified .env.example PENDING

Create: /Users/kunthawatgreethong/Gitea/opencode-skill/.env.example

# ===========================================
# OPENCODE SKILLS - UNIFIED CONFIGURATION
# ===========================================
# Copy this file to .env and fill in your values
# This file is shared by ALL skills
# ===========================================

# Gitea Configuration
# Get API token from: https://git.moreminimore.com/user/settings/applications
GITEA_URL=https://git.moreminimore.com
GITEA_API_TOKEN=
GITEA_USERNAME=

# Easypanel Configuration
# Login credentials for auto-deployment
EASYPANEL_URL=http://110.164.146.47:3000
EASYPANEL_USERNAME=
EASYPANEL_PASSWORD=
EASYPANEL_DEFAULT_PROJECT=default

# Website Defaults
# Applied to all generated websites
ADMIN_PASSWORD=
UMAMI_DOMAIN=analytics.example.com

# Optional: Umami Analytics
# Leave empty if not using
UMAMI_WEBSITE_ID=

📊 DEPLOYMENT WORKFLOW

Complete Auto-Deploy Flow

User runs:
python3 create_astro_website.py --name "mysite" --output "./mysite"
         ↓
1. Generate website structure
   - Astro project
   - PDPA pages
   - Docker files
         ↓
2. Auto-sync to Gitea (NEW)
   - Check if repo exists
   - Create if new
   - Update if exists
   - Push code
         ↓
3. Auto-deploy to Easypanel (NEW)
   - Authenticate (username/pass → token)
   - Create project
   - Create service
   - Connect Git
   - Set build type (Dockerfile)
   - Trigger deployment
         ↓
4. Return deployment URL
   ✅ https://mysite.easypanel.app

🔧 ENVIRONMENT VARIABLE FLOW

Development:
┌─────────────────────────────────────┐
│ /Users/kunthawatgreethong/Gitea/    │
│   opencode-skill/.env               │ ← User edits this
│                                     │
│ [GITEA_API_TOKEN=xxx]               │
│ [EASYPANEL_USERNAME=xxx]            │
│ [ADMIN_PASSWORD=xxx]                │
└──────────────┬──────────────────────┘
               │
               │ install-skills.sh reads
               ↓
┌─────────────────────────────────────┐
│ ~/.config/opencode/.env             │ ← Skills read this
│ (copied from repo root)             │
└──────────────┬──────────────────────┘
               │
               │ Python scripts load via:
               │ load_env() from parent
               ↓
┌─────────────────────────────────────┐
│ skills/
│  ├── gitea-sync/scripts/sync.py    │
│  ├── easypanel-deploy/scripts/     │
│  └── website-creator/scripts/      │
└─────────────────────────────────────┘

🎯 IMPLEMENTATION PRIORITY

Must Have (MVP)

  1. easypanel-deploy script - DONE
  2. gitea-sync script
  3. Unified .env.example
  4. Updated install-skills.sh

Should Have

  1. website-creator integration
  2. Auto-deploy on generation

Nice to Have

  1. Status checking
  2. Rollback capability
  3. Multi-project support

⚠️ KNOWN ISSUES TO FIX

easypanel-deploy

  • LSP errors (minor, script works)
  • Need to test authentication flow
  • Error handling needs improvement

gitea-sync

  • Not yet created
  • Need Gitea API token from user

install-skills.sh

  • Doesn't handle unified .env yet
  • Doesn't update existing installations

🧪 TESTING PLAN

Test 1: easypanel-deploy

cd skills/easypanel-deploy
python3 scripts/deploy.py --help
# Should show all options

Test 2: gitea-sync

cd skills/gitea-sync
python3 scripts/sync.py --help
# Should show all options

Test 3: Unified .env

cd /Users/kunthawatgreethong/Gitea/opencode-skill
./scripts/install-skills.sh
# Should prompt for unified .env
# Should copy to ~/.config/opencode/.env

Test 4: End-to-End

python3 scripts/create_astro_website.py \
  --name "test-site" \
  --auto-deploy  # NEW flag
# Should: generate → gitea → easypanel → URL

📝 NEXT STEPS

Immediate (User Action Required)

  1. Provide Gitea API Token

  2. Verify Easypanel Credentials

    • Test username/password
    • Confirm API access works
  3. Review This Plan

    • Confirm architecture is correct
    • Approve before I continue implementation

Next Implementation Session

  1. Create gitea-sync skill
  2. Create unified .env.example
  3. Update install-skills.sh
  4. Integrate with website-creator
  5. Test complete workflow

QUESTIONS FOR USER

  1. Gitea Organization: Should repos be created under your personal account or an organization?

    • Your answer: Personal account
  2. Easypanel Auth: Confirm username/password works (not just API token)

    • Your answer: Username/password preferred
  3. Unified .env Location: Confirm locations

    • Dev: /Users/kunthawatgreethong/Gitea/opencode-skill/.env
    • Production: ~/.config/opencode/.env
  4. Auto-Deploy Default: Should auto-deploy be:

    • A) Always on (every website auto-deploys)
    • B) Optional (--auto-deploy flag)
    • C) Ask interactively

Status: Ready to proceed with Phase 2 (gitea-sync) pending your review of this plan.