-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·175 lines (148 loc) · 4.76 KB
/
deploy.sh
File metadata and controls
executable file
·175 lines (148 loc) · 4.76 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#!/bin/bash
# MultiLineDiff Website Deployment Script
# Usage: ./deploy.sh [environment]
# Environments: dev, staging, production
set -e
ENVIRONMENT=${1:-dev}
SITE_URL="https://d1f.ai"
echo "🚀 Deploying MultiLineDiff Website to $ENVIRONMENT..."
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Function to print colored output
print_status() {
echo -e "${BLUE}[INFO]${NC} $1"
}
print_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Check if we're in the website directory
if [ ! -f "index.html" ]; then
print_error "Please run this script from the website directory"
exit 1
fi
# Validate HTML
print_status "Validating HTML..."
if command -v html5validator &> /dev/null; then
html5validator --root . --also-check-css
print_success "HTML validation passed"
else
print_warning "html5validator not found, skipping HTML validation"
fi
# Check for required files
print_status "Checking required files..."
required_files=("index.html" "css/styles.css" "js/main.js" "images/favicon.svg")
for file in "${required_files[@]}"; do
if [ ! -f "$file" ]; then
print_error "Required file missing: $file"
exit 1
fi
done
print_success "All required files present"
# Optimize files for production
if [ "$ENVIRONMENT" = "production" ]; then
print_status "Optimizing files for production..."
# Create optimized directory
mkdir -p dist
cp -r . dist/
cd dist
# Remove development files
rm -f deploy.sh README.md
# Minify CSS (if csso is available)
if command -v csso &> /dev/null; then
print_status "Minifying CSS..."
for css_file in css/*.css; do
csso "$css_file" --output "$css_file"
done
print_success "CSS minified"
else
print_warning "csso not found, skipping CSS minification"
fi
# Minify JavaScript (if uglifyjs is available)
if command -v uglifyjs &> /dev/null; then
print_status "Minifying JavaScript..."
for js_file in js/*.js; do
uglifyjs "$js_file" --compress --mangle --output "$js_file"
done
print_success "JavaScript minified"
else
print_warning "uglifyjs not found, skipping JavaScript minification"
fi
cd ..
print_success "Production optimization complete"
fi
# Deploy based on environment
case $ENVIRONMENT in
"dev")
print_status "Starting local development server..."
if command -v python3 &> /dev/null; then
python3 -m http.server 8000
elif command -v python &> /dev/null; then
python -m http.server 8000
elif command -v php &> /dev/null; then
php -S localhost:8000
else
print_error "No suitable HTTP server found. Please install Python or PHP."
exit 1
fi
;;
"staging")
print_status "Deploying to staging environment..."
# Add staging deployment logic here
# Example: rsync to staging server
# rsync -avz --delete . user@staging-server:/var/www/staging/
print_warning "Staging deployment not configured"
;;
"production")
print_status "Deploying to production environment..."
# Example Netlify deployment
if command -v netlify &> /dev/null; then
print_status "Deploying to Netlify..."
if [ -d "dist" ]; then
netlify deploy --prod --dir=dist
else
netlify deploy --prod --dir=.
fi
print_success "Deployed to Netlify"
else
print_warning "Netlify CLI not found"
print_status "Manual deployment required:"
echo "1. Upload files to your hosting provider"
echo "2. Configure domain: $SITE_URL"
echo "3. Enable HTTPS"
echo "4. Set up CDN if available"
fi
;;
*)
print_error "Unknown environment: $ENVIRONMENT"
print_status "Available environments: dev, staging, production"
exit 1
;;
esac
print_success "Deployment complete! 🎉"
if [ "$ENVIRONMENT" = "dev" ]; then
echo ""
print_status "Local development server running at:"
echo " http://localhost:8000"
echo ""
print_status "Press Ctrl+C to stop the server"
elif [ "$ENVIRONMENT" = "production" ]; then
echo ""
print_status "Production site should be available at:"
echo " $SITE_URL"
echo ""
print_status "Don't forget to:"
echo " • Test the live site"
echo " • Update DNS if needed"
echo " • Monitor performance"
echo " • Check analytics"
fi