Files
ai-recruit-site-template/.gitignore
Mikael Westöö d28fb10360 Implement enhanced deployment script with auto-detection
Major Enhancement: Smart deployment with setup/update modes

Features Added:
==============

1. **Auto-Detection Mode** (default)
   - Checks for .deployment-uuid file
   - First run → Setup mode (creates new deployment)
   - Subsequent runs → Update mode (updates existing)
   - No flags needed for common workflows

2. **Three Operation Modes:**

   A. Setup Mode (--setup or auto if no UUID)
      - Creates NEW application via POST /api/v1/applications
      - Saves UUID to .deployment-uuid file (git-ignored)
      - Sets up Gitea webhook (one-time)
      - Warns if UUID file already exists

   B. Update Mode (--update or auto if UUID exists)
      - Reads UUID from .deployment-uuid
      - Verifies application exists: GET /api/v1/applications/:uuid
      - Updates env vars: PATCH /api/v1/applications/:uuid/env
      - Triggers redeploy: POST /api/v1/applications/:uuid/deploy
      - GITEA_API_TOKEN not required (webhook already configured)

   C. Status Mode (--status)
      - Fetches current deployment details
      - Shows application info, status, domain
      - Provides monitoring commands

3. **UUID Persistence**
   - .deployment-uuid file stores application UUID
   - Enables stateful deployments
   - Prevents duplicate application creation
   - Git-ignored for security

4. **Improved User Experience**
   - Clear mode indication (SETUP/UPDATE/STATUS)
   - Verification step before overwriting existing deployment
   - Comprehensive error messages with actionable steps
   - Updated deployment-info.txt with mode information
   - Smart dependency checks (GITEA_TOKEN only for setup)

5. **Updated .gitignore**
   - Added .deployment-uuid to prevent accidental commits

Usage Examples:
===============

# First deployment (auto-detects no UUID → setup)
./deploy-to-apps.sh
→ Creates application, saves UUID, sets up webhook

# Update after changing .env (auto-detects UUID → update)
./deploy-to-apps.sh
→ Updates env vars, triggers redeployment

# Force new deployment
./deploy-to-apps.sh --setup

# Check status
./deploy-to-apps.sh --status

Benefits:
=========
 Idempotent - Can run multiple times safely
 Stateful - Remembers previous deployments
 User-friendly - Automatic mode detection
 Safe - Prevents duplicate applications
 Flexible - Supports multiple scenarios
 Clear feedback - Shows exactly what's happening

Files Modified:
===============
- deploy-to-apps.example.sh: Complete rewrite with 3 modes
- .gitignore: Added .deployment-uuid
- DEPLOYMENT_SCRIPT_PROPOSAL.md: Full design document

Migration for Existing Users:
==============================
If you already deployed with the old script:
1. Find your UUID: curl -H "X-API-Key: $SAAC_API_KEY" $SAAC_API/applications
2. Save it: echo "your-uuid" > .deployment-uuid
3. Run updates: ./deploy-to-apps.sh

🤖 Generated with Claude Code
https://claude.com/claude-code

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-24 17:42:08 +01:00

232 B