-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy-watch.sh
More file actions
36 lines (25 loc) · 993 Bytes
/
Copy pathdeploy-watch.sh
File metadata and controls
36 lines (25 loc) · 993 Bytes
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
#!/bin/bash
# Ensure PATH includes necessary binaries
export PATH="/usr/local/go/bin:/usr/local/bin:/usr/bin:/bin:$HOME/.local/bin:$HOME/go/bin:$PATH"
echo "Watching for changes and auto-deploying..."
while true; do
# Get current commit hash before pulling
OLD_COMMIT=$(git rev-parse HEAD)
git pull origin main > /dev/null 2>&1
# Get commit hash after pulling
NEW_COMMIT=$(git rev-parse HEAD)
# Only rebuild if commit changed
if [ "$OLD_COMMIT" != "$NEW_COMMIT" ]; then
echo "New changes detected! Building..."
echo "Building backend..."
go build -o golf-card-game
echo "Building frontend..."
cd frontend && npm run build && cd ..
# Restart systemd service
echo "Restarting service..."
sudo systemctl restart golf
echo "Deployment complete at $(date)"
fi
# Wait before checking again (e.g., every 30 seconds)
sleep 30
done