-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·109 lines (89 loc) · 2.99 KB
/
deploy.sh
File metadata and controls
executable file
·109 lines (89 loc) · 2.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/bash
# Cards Forge Deployment Script
# This script handles safe deployment with proper cache management
set -e # Exit on any error
echo "🚀 Starting deployment..."
# Detect environment
if [ -f .env ]; then
APP_ENV=$(grep APP_ENV .env | cut -d '=' -f2 | tr -d '"' | tr -d "'" | xargs)
else
APP_ENV="production"
fi
echo "🌍 Environment detected: ${APP_ENV}"
if [ "$APP_ENV" = "production" ]; then
# Pull latest code from git
echo "📥 Pulling latest code from git..."
git pull
fi
# Install/update PHP dependencies
echo "📦 Installing Composer dependencies..."
if [ "$APP_ENV" = "production" ]; then
# Check if composer.lock is missing or out of sync
if [ ! -f composer.lock ] || ! php composer.phar validate --no-check-all --quiet 2>/dev/null; then
echo " ⚠️ Cleaning vendor directory for fresh install..."
rm -rf vendor/
fi
echo " Using production mode (--no-dev)"
php composer.phar install --no-dev --optimize-autoloader --no-interaction
else
# Check if composer.lock is missing or out of sync
if [ ! -f composer.lock ] || ! composer validate --no-check-all --quiet 2>/dev/null; then
echo " ⚠️ Cleaning vendor directory for fresh install..."
rm -rf vendor/
fi
echo " Using development mode (with dev dependencies)"
composer install --optimize-autoloader --no-interaction
fi
# Run database migrations
echo "🗄️ Running database migrations..."
php artisan migrate --force
# Run NPM build on dev
echo "Start NPM production build..."
if [ "$APP_ENV" = "production" ]; then
echo " - Skipping because NPM not installed on production"
else
npm run build
fi
# Clear all caches
echo "🧹 Clearing application caches..."
php artisan cache:clear
php artisan config:clear
php artisan route:clear
php artisan view:clear
# Cache configuration for better performance
echo "⚡ Caching configuration..."
php artisan config:cache
php artisan route:cache
php artisan view:cache
# Clear and cache Filament components
echo "💎 Refreshing Filament components..."
php artisan filament:cache-components
# Upgrade Filament assets
echo "🔄 Upgrading Filament assets..."
php artisan filament:upgrade
# Optimize autoloader
echo "🔧 Optimizing autoloader..."
if [ "$APP_ENV" = "production" ]; then
php composer.phar dump-autoload --optimize --no-dev
else
composer dump-autoload --optimize
fi
# Restart queue workers (if running)
echo "🔄 Restarting queue workers..."
php artisan queue:restart
# Clear all optimization caches
echo "🚀 Clearing optimization caches..."
php artisan optimize:clear
echo ""
echo "✅ Deployment completed successfully!"
echo ""
echo "📊 Environment: ${APP_ENV}"
echo ""
echo "📋 Verification checklist:"
echo " ✓ Queue workers restarted and processing jobs"
echo " ✓ All caches cleared and regenerated"
if [ "$APP_ENV" = "production" ]; then
echo " ✓ Dev dependencies excluded (production mode)"
else
echo " ✓ Dev dependencies included (development mode)"
fi