280 lines
13 KiB
Markdown
280 lines
13 KiB
Markdown
---
|
|
description: Deploy application to Eureka platform (creates app if needed)
|
|
allowed-tools: Read, Write, Edit, Bash, Glob, Grep
|
|
---
|
|
|
|
# Eureka Deploy
|
|
|
|
**Input**: "$ARGUMENTS"
|
|
|
|
---
|
|
|
|
## PURPOSE
|
|
|
|
Deploy the current project to the Eureka platform. If no `app_id` is configured, automatically creates a new directory app first, then triggers the deployment.
|
|
|
|
---
|
|
|
|
## ⛔ CRITICAL RULES
|
|
|
|
### MUST DO
|
|
1. **MUST** check for existing `app_id` in `.claude/eureka-factory.yaml` first
|
|
2. **MUST** create a new app via API if no `app_id` exists
|
|
3. **MUST** save the new `app_id` to config after creation
|
|
4. **MUST** display deployment status after triggering
|
|
|
|
### CANNOT DO
|
|
1. **CANNOT** deploy without valid API key
|
|
2. **CANNOT** skip app creation if `app_id` is missing
|
|
3. **CANNOT** proceed if API calls fail
|
|
|
|
---
|
|
|
|
## EXECUTION FLOW
|
|
|
|
### ═══════════════════════════════════════════════════════════════
|
|
### PHASE 1: Configuration Check
|
|
### ═══════════════════════════════════════════════════════════════
|
|
|
|
#### 1.1: Display Start Banner
|
|
|
|
```
|
|
╔══════════════════════════════════════════════════════════════╗
|
|
║ 🚀 EUREKA DEPLOY ║
|
|
╠══════════════════════════════════════════════════════════════╣
|
|
║ Deploying to Eureka Platform... ║
|
|
╚══════════════════════════════════════════════════════════════╝
|
|
```
|
|
|
|
#### 1.2: Check Configuration
|
|
|
|
Read the configuration file:
|
|
```bash
|
|
# Check if config exists
|
|
cat .claude/eureka-factory.yaml 2>/dev/null || cat .claude/eureka-factory.yml 2>/dev/null || echo "NO_CONFIG"
|
|
```
|
|
|
|
**Extract from config:**
|
|
- `api_key` - Required for all operations
|
|
- `app_id` - If exists, skip app creation
|
|
- `api_endpoint` - Optional custom endpoint
|
|
|
|
#### 1.3: Validate API Key
|
|
|
|
If no `api_key` found:
|
|
```
|
|
╔══════════════════════════════════════════════════════════════╗
|
|
║ ❌ NO API KEY CONFIGURED ║
|
|
╠══════════════════════════════════════════════════════════════╣
|
|
║ Run `eureka setup` to configure your credentials. ║
|
|
╚══════════════════════════════════════════════════════════════╝
|
|
```
|
|
**STOP EXECUTION**
|
|
|
|
---
|
|
|
|
### ═══════════════════════════════════════════════════════════════
|
|
### PHASE 2: App Creation (if needed)
|
|
### ═══════════════════════════════════════════════════════════════
|
|
|
|
#### 2.1: Check for app_id
|
|
|
|
If `app_id` exists in config → **SKIP TO PHASE 3**
|
|
|
|
If `app_id` is missing:
|
|
|
|
```
|
|
╔══════════════════════════════════════════════════════════════╗
|
|
║ 📁 CREATING DIRECTORY APP ║
|
|
╠══════════════════════════════════════════════════════════════╣
|
|
║ No app_id found. Creating new app on Eureka... ║
|
|
╚══════════════════════════════════════════════════════════════╝
|
|
```
|
|
|
|
#### 2.2: Determine App Name
|
|
|
|
Use the project directory name as the default app name:
|
|
```bash
|
|
APP_NAME=$(basename $(pwd))
|
|
echo "App name: $APP_NAME"
|
|
```
|
|
|
|
Or use argument if provided: `$ARGUMENTS` as app name
|
|
|
|
#### 2.3: Create App via API
|
|
|
|
```bash
|
|
# Create app using eureka CLI
|
|
eureka deploy trigger --name "$APP_NAME" --type other --yes
|
|
```
|
|
|
|
**If the command is not available, use direct API call:**
|
|
|
|
```bash
|
|
API_KEY="<from config>"
|
|
API_ENDPOINT="<from config or default>"
|
|
|
|
curl -X POST "${API_ENDPOINT}/v1/apps" \
|
|
-H "Content-Type: application/json" \
|
|
-H "X-API-Key: ${API_KEY}" \
|
|
-d "{\"name\": \"${APP_NAME}\", \"type\": \"other\"}"
|
|
```
|
|
|
|
#### 2.4: Save app_id to Config
|
|
|
|
Extract `app_id` from API response and update config:
|
|
|
|
```yaml
|
|
# .claude/eureka-factory.yaml
|
|
api_key: <existing>
|
|
project_id: <existing>
|
|
repo_id: <existing>
|
|
app_id: <NEW_APP_ID> # Add this line
|
|
```
|
|
|
|
```
|
|
╔══════════════════════════════════════════════════════════════╗
|
|
║ ✅ APP CREATED ║
|
|
╠══════════════════════════════════════════════════════════════╣
|
|
║ App ID: <app_id> ║
|
|
║ Saved to: .claude/eureka-factory.yaml ║
|
|
╚══════════════════════════════════════════════════════════════╝
|
|
```
|
|
|
|
---
|
|
|
|
### ═══════════════════════════════════════════════════════════════
|
|
### PHASE 3: Trigger Deployment
|
|
### ═══════════════════════════════════════════════════════════════
|
|
|
|
#### 3.1: Trigger Deploy
|
|
|
|
```bash
|
|
# Using eureka CLI
|
|
eureka deploy trigger --yes
|
|
|
|
# Or direct API call
|
|
curl -X POST "${API_ENDPOINT}/v1/apps/${APP_ID}/deployments" \
|
|
-H "Content-Type: application/json" \
|
|
-H "X-API-Key: ${API_KEY}" \
|
|
-d '{"environment": "production"}'
|
|
```
|
|
|
|
#### 3.2: Display Deployment Status
|
|
|
|
```
|
|
╔══════════════════════════════════════════════════════════════╗
|
|
║ ✅ DEPLOYMENT TRIGGERED ║
|
|
╠══════════════════════════════════════════════════════════════╣
|
|
║ Deployment ID: <deployment_id> ║
|
|
║ Status: PENDING ║
|
|
║ Environment: production ║
|
|
║ Version: <version> ║
|
|
╠══════════════════════════════════════════════════════════════╣
|
|
║ Use `/eureka:deploy-status` to check progress ║
|
|
║ Use `/eureka:deploy-logs` to view logs ║
|
|
╚══════════════════════════════════════════════════════════════╝
|
|
```
|
|
|
|
---
|
|
|
|
## ARGUMENTS
|
|
|
|
| Argument | Default | Description |
|
|
|----------|---------|-------------|
|
|
| `[app-name]` | Directory name | Name for new app (only used if creating) |
|
|
| `--env <environment>` | `production` | Deployment environment |
|
|
| `--branch <branch>` | Current branch | Git branch to deploy |
|
|
| `--force` | `false` | Force deploy even if already deploying |
|
|
|
|
## EXAMPLES
|
|
|
|
```bash
|
|
# Deploy current project (creates app if needed)
|
|
/eureka:deploy
|
|
|
|
# Deploy with custom app name
|
|
/eureka:deploy my-awesome-app
|
|
|
|
# Deploy specific branch to staging
|
|
/eureka:deploy --env staging --branch develop
|
|
|
|
# Force redeploy
|
|
/eureka:deploy --force
|
|
```
|
|
|
|
---
|
|
|
|
## ERROR HANDLING
|
|
|
|
### No Configuration
|
|
```
|
|
❌ No configuration found.
|
|
Run `eureka setup` to configure credentials.
|
|
```
|
|
|
|
### App Creation Failed
|
|
```
|
|
❌ Failed to create app: <error message>
|
|
Check your API key and try again.
|
|
```
|
|
|
|
### Deployment Failed
|
|
```
|
|
❌ Deployment failed: <error message>
|
|
Use `/eureka:deploy-logs` to see details.
|
|
```
|
|
|
|
---
|
|
|
|
## FLOW DIAGRAM
|
|
|
|
```
|
|
┌─────────────────────────────────────────────────────────────────┐
|
|
│ /eureka:deploy │
|
|
├─────────────────────────────────────────────────────────────────┤
|
|
│ │ │
|
|
│ ▼ │
|
|
│ ┌─────────────────┐ │
|
|
│ │ Check Config │ │
|
|
│ └────────┬────────┘ │
|
|
│ │ │
|
|
│ ┌─────────▼─────────┐ │
|
|
│ │ Has API Key? │ │
|
|
│ └─────────┬─────────┘ │
|
|
│ │ │
|
|
│ NO │ YES │
|
|
│ ┌────────────────────┼────────────────────┐ │
|
|
│ ▼ ▼ │
|
|
│ ┌───────────┐ ┌─────────────────┐ │
|
|
│ │ ERROR │ │ Has app_id? │ │
|
|
│ │ No Key │ └────────┬────────┘ │
|
|
│ └───────────┘ │ │
|
|
│ NO │ YES │
|
|
│ ┌───────────────────┼──────────┐ │
|
|
│ ▼ ▼ │
|
|
│ ┌─────────────────┐ ┌──────────────┐
|
|
│ │ Create App │ │ │
|
|
│ │ via API │ │ │
|
|
│ └────────┬────────┘ │ │
|
|
│ │ │ │
|
|
│ ▼ │ │
|
|
│ ┌─────────────────┐ │ │
|
|
│ │ Save app_id │ │ │
|
|
│ │ to Config │ │ │
|
|
│ └────────┬────────┘ │ │
|
|
│ │ │ │
|
|
│ └───────────────────┘ │
|
|
│ │ │
|
|
│ ▼ │
|
|
│ ┌─────────────────┐ │
|
|
│ │ Trigger Deploy │ │
|
|
│ └────────┬────────┘ │
|
|
│ │ │
|
|
│ ▼ │
|
|
│ ┌─────────────────┐ │
|
|
│ │ Show Status │ │
|
|
│ └─────────────────┘ │
|
|
└─────────────────────────────────────────────────────────────────┘
|
|
```
|