-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy-project.sh
More file actions
executable file
·50 lines (40 loc) · 1.22 KB
/
Copy pathdeploy-project.sh
File metadata and controls
executable file
·50 lines (40 loc) · 1.22 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
#!/bin/bash
# ============================================================
# Deploy a project (pull from GitHub + rebuild)
# Usage: ./deploy-project.sh <project-name> [github-url]
# ============================================================
set -e
PROJECT_NAME="${1}"
GITHUB_URL="${2}"
BASE_DIR="/home/elkayam/dev-env"
PROJECT_DIR="$BASE_DIR/projects/$PROJECT_NAME"
if [ -z "$PROJECT_NAME" ]; then
echo "Usage: $0 <project-name> [github-url]"
echo "Example: $0 myapp https://github.com/user/myapp.git"
exit 1
fi
if [ ! -d "$PROJECT_DIR" ]; then
echo "Project not found: $PROJECT_DIR"
exit 1
fi
echo "Deploying: $PROJECT_NAME"
echo "========================"
cd "$PROJECT_DIR"
# Add GitHub remote if provided
if [ -n "$GITHUB_URL" ]; then
if git remote | grep -q "origin"; then
git remote set-url origin "$GITHUB_URL"
else
git remote add origin "$GITHUB_URL"
fi
fi
# Pull latest
if git remote | grep -q "origin"; then
echo "Pulling latest code..."
git pull origin main 2>/dev/null || git pull origin master 2>/dev/null || echo "No remote changes"
fi
# Rebuild
echo "Building containers..."
docker compose up -d --build
echo ""
echo "Deployed: https://$PROJECT_NAME.apps.elkayam.me"