-
Notifications
You must be signed in to change notification settings - Fork 0
49 lines (40 loc) · 1.3 KB
/
deploy.yml
File metadata and controls
49 lines (40 loc) · 1.3 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
name: Deploy to VPS
on:
push:
branches: [ main ]
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
environment: production
steps:
- name: Setup SSH key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.DEPLOY_KEY }}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
ssh-keyscan -H vps.marottanicolo.me >> ~/.ssh/known_hosts
- name: Deploy application on VPS
run: |
ssh gh-actions@vps.marottanicolo.me << 'EOF'
cd /home/shared/DockerChat
# Force pull latest changes (overwrites local changes)
git fetch origin main
git reset --hard origin/main
# Stop existing containers
docker compose down || true
# Build and start services
docker compose up --build -d
# Show running containers
docker compose ps
EOF
- name: Health check
run: |
sleep 30
ssh gh-actions@vps.marottanicolo.me << 'EOF'
cd /home/shared/DockerChat
echo "=== Container Status ==="
docker compose ps
echo "=== Container Logs (last 50 lines) ==="
docker compose logs --tail=50
EOF