Skill: joshualeecowan33-ui/blue-green-deployer (version 2.0.0)

--- name: blue-green-deployer version: 2.0.0 description: A specialized skill for safely managing and testing OpenClaw configuration changes using a Blue/Green deployment pattern. Use when you need to test new settings, tools, or channel configurations without risking the stability of the main (Blue) session. dependencies: - openclaw - jq --- # Blue/Green Deployer This skill provides a structured pre-production testing workflow for OpenClaw configuration changes using a Blue/Green deployment pattern. ## Workflow ### 1. Setup the Green Environment Initialize the testing area by creating the Green configuration from your current Blue master. - Command: `bash <skill-path>/scripts/deploy.sh` ### 2. Experiment Modify the files within the `green` configuration folder or the `openclaw.json.green` file directly using your preferred editor. ### 3. Audit and Validate Verify that the changes in the Green environment are valid and do not break the OpenClaw service. - **Step A**: Check JSON syntax: `jq empty openclaw.json.green` - **Step B**: Run the deployment script to perform the symlink-based validation check. ### 4. Promote or Rollback - **To Promote**: If the audit passes, the `deploy.sh` script will automatically promote the Green configuration to Blue. - **To Rollback**: If the audit fails, the `deploy.sh` (or manual action) will revert the Blue configuration to its previous state using the `.bak` file. ## Troubleshooting - **Validation Error**: If the script reports a failure, check the `openclaw.json.green` file for syntax errors (missing commas, brackets) or invalid keys. - **Manual Check**: Always use `openclaw status` after any deployment to ensure the live service is operational.

path: scripts/deploy.sh
content: #!/bin/bash
# Blue/Green Deployment Script for OpenClaw Config
# Implements: Clone -> Experiment -> Audit (via Symlink) -> Promote/Rollback
# Version 2.0 (Refactored for safety and reliability)

# Exit on error, undefined variables, and pipe failures
set -euo pipefail

# Paths
BLUE_CONFIG="$HOME/.openclaw/openclaw.json"
GREEN_CONFIG="$HOME/.openclaw/openclaw.json.green"
BACKUP_CONFIG="$HOME/.openclaw/openclaw.json.bak"
AUDIT_LINK="$HOME/.openclaw/openclaw.json.audit"

# Cleanup function to be called on error or exit
cleanup() {
    local exit_code=$?
    if [ $exit_code -ne 0 ]; then
        echo "⚠️  An error occurred. Performing emergency cleanup..."
        # If we left a .tmp file, try to restore it
        if [ -f "${BLUE_CONFIG}.tmp" ]; then
            mv "${BLUE_LONG_NAME:-${BLUE_CONFIG}.tmp}" "$BLUE_CONFIG" 2>/dev/null || true
        fi
    fi
    # Remove the audit symlink if it exists
    [ -L "$AUDIT_LINK" ] && rm "$AUDIT_LINK"
}

trap cleanup EXIT

echo "🚀 Starting Blue/Green Deployment Process (v2)..."

# 1. Setup: Ensure Green exists and is a clone of Blue
if [ ! -f "$BLUE_CONFIG" ]; then
    echo "❌ Error: Blue configuration ($BLUE_CONFIG) not found!"
    exit 1
fi

if [ ! -f "$GREEN_CONFIG" ]; then
    echo "📂 Creating Green (Tester) config from Blue..."
    cp "$BLUE_CONFIG" "$GREEN_CONFIG"
fi

# 2. The Audit (The core logic)
echo "🔍 Preparing Audit link..."

# Create a robust backup of the current Blue
cp "$BLUE_CONFIG" "$BACKUP_CONFIG"

# Create the audit symlink pointing to Green
ln -sf "$GREEN_CONFIG" "$AUDIT_LINK"

# 3. Validation
# We use a temporary file to perform the swap safely.
echo "🧪 Running validation against the Audit link..."

# Create a temporary copy of Blue to swap in
cp "$BLUE_CONFIG" "${BLUE_CONFIG}.tmp"

# Point Blue to the Audit link (which points to Green)
# Note: We are effectively making the 'real' config file a symlink to Green for the test
rm "$BLUE_CONFIG"
ln -s "$AUDIT_LINK" "$BLUE_CONFIG"

# Execute the check
# We use 'openclaw status' - we assume this command exists in the PATH/environment
if openclaw status > /dev/null 2>&1; then
    echo "✅ SUCCESS: Green configuration is valid!"
    echo "🎉 Promoting Green to Blue..."
    
    # To promote, we replace the symlink with the actual content of Green
    rm "$BLUE_CONFIG"
    cp "$GREEN_CONFIG" "$BLUE_CONFIG"
    
    echo "🚀 Deployment complete. Blue is now updated."
else
    echo "❌ FAILURE: Green configuration is invalid!"
    echo "🚨 Rolling back Blue to original state..."
    
    # Restore from backup
    rm "$BLUE_CONFIG"
    cp "$BACKUP_CONFIG" "$BLUE_CONFIG"
    
    echo "🔄 Rollback complete. Blue is restored."
    exit 1
fi


Security scan verdicts — ClawScan: suspicious | static analysis: clean | VirusTotal: clean | SkillSpector: suspicious (MEDIUM)