-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
Β·59 lines (46 loc) Β· 1.21 KB
/
deploy.sh
File metadata and controls
executable file
Β·59 lines (46 loc) Β· 1.21 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
#!/bin/bash
set -euo pipefail
DOMAIN="rswfire.dev"
APP_DIR="/home/rswfire/www/rswfire.dev"
BRANCH="main"
echo "π Deploying $DOMAIN to server..."
echo "π Branch: $BRANCH"
echo "π Directory: $APP_DIR"
echo ""
if [ ! -d "$APP_DIR" ]; then
echo "β Error: Directory $APP_DIR does not exist"
exit 1
fi
cd "$APP_DIR"
echo "π Current git status:"
git status --short
echo ""
echo "β¬οΈ Fetching latest changes..."
git fetch origin "$BRANCH"
git reset --hard "origin/$BRANCH"
echo ""
echo "π§Ή Cleaning old build..."
[ -d "node_modules" ] && rm -rf node_modules
[ -d "out" ] && rm -rf out
echo ""
echo "π¦ Installing dependencies..."
npm ci
echo ""
echo "π¨ Building application..."
npm run build
if [ ! -d "out" ]; then
echo "β Error: Build failed - no 'out' directory created"
exit 1
fi
BUILD_SIZE=$(du -sh out | cut -f1)
echo "β
Build successful - $BUILD_SIZE generated"
echo ""
# Optional SSR build
if [ -f "package.json" ] && grep -q "\"build:ssr\"" package.json; then
echo "π§ Running SSR build..."
npm run build:ssr
echo ""
fi
echo "β
Deploy complete"
echo "π Commit: $(git rev-parse --short HEAD) ($(git log -1 --pretty=%B | head -n1))"
echo "β± Finished: $(date)"