salesforce-composite-envelo.../composite-envelope-builder/deploy.sh

92 lines
2.2 KiB
Bash
Executable File

#!/bin/bash
# Deployment script for Salesforce Composite Envelope Builder
echo "🚀 Salesforce Composite Envelope Builder Deployment"
echo "=================================================="
echo ""
# Check if sf CLI is installed
if ! command -v sf &> /dev/null; then
echo "❌ Salesforce CLI not found. Please install it first:"
echo " npm install -g @salesforce/cli"
exit 1
fi
echo "✅ Salesforce CLI found: $(sf --version)"
echo ""
# Ask for org type
echo "Which org do you want to deploy to?"
echo "1) Sandbox"
echo "2) Production"
read -p "Enter choice (1 or 2): " ORG_CHOICE
if [ "$ORG_CHOICE" == "1" ]; then
ORG_TYPE="sandbox"
INSTANCE_URL="https://test.salesforce.com"
ORG_ALIAS="composite-envelope-sandbox"
elif [ "$ORG_CHOICE" == "2" ]; then
ORG_TYPE="production"
INSTANCE_URL="https://login.salesforce.com"
ORG_ALIAS="composite-envelope-production"
else
echo "❌ Invalid choice. Exiting."
exit 1
fi
echo ""
echo "📝 Deploying to: $ORG_TYPE"
echo "🔗 Instance URL: $INSTANCE_URL"
echo "🏷️ Org Alias: $ORG_ALIAS"
echo ""
# Authorize org
echo "🔐 Authorizing org..."
sf org login web --alias "$ORG_ALIAS" --instance-url "$INSTANCE_URL"
if [ $? -ne 0 ]; then
echo "❌ Authorization failed. Exiting."
exit 1
fi
echo "✅ Authorization successful"
echo ""
# Set default org
echo "⚙️ Setting default org..."
sf config set target-org "$ORG_ALIAS"
echo ""
echo "📦 Deploying metadata..."
sf project deploy start --target-org "$ORG_ALIAS"
if [ $? -ne 0 ]; then
echo "❌ Deployment failed. Check errors above."
exit 1
fi
echo ""
echo "✅ Deployment successful!"
echo ""
# Run tests
echo "🧪 Running unit tests..."
sf apex run test --wait 10 --result-format human --code-coverage --target-org "$ORG_ALIAS"
if [ $? -ne 0 ]; then
echo "⚠️ Some tests failed. Please review."
else
echo "✅ All tests passed!"
fi
echo ""
echo "=================================================="
echo "✅ Deployment Complete!"
echo ""
echo "Next steps:"
echo "1. Configure Docusign credentials in Salesforce"
echo "2. Update your Screen Flow to call the Apex Action"
echo "3. Test with real Docusign templates"
echo ""
echo "See docs/deployment-guide.md for detailed instructions."