Repository navigation
70 lines (62 loc) · 2.14 KB
/
Copy pathdeploy.yml
File metadata and controls
70 lines (62 loc) · 2.14 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
name: Deploy to Production
on:
push:
branches: [main]
workflow_dispatch:
jobs:
deploy:
name: Deploy to minis
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Tailscale
uses: tailscale/github-action@v3
with:
oauth-client-id: ${{ secrets.TAILSCALE_OAUTH_CLIENT_ID }}
oauth-secret: ${{ secrets.TAILSCALE_OAUTH_SECRET }}
tags: tag:ci
- name: Wait for Tailscale DNS
run: |
for i in $(seq 1 30); do
if tailscale status --peers | grep -q minis; then
echo "Tailscale peer 'minis' found"
break
fi
echo "Waiting for Tailscale... ($i/30)"
sleep 2
done
- name: Setup SSH key
run: |
MINIS_IP=$(tailscale ip -4 minis 2>/dev/null || echo "100.100.181.45")
echo "MINIS_IP=$MINIS_IP" >> $GITHUB_ENV
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_deploy
chmod 600 ~/.ssh/id_deploy
ssh-keyscan -H $MINIS_IP >> ~/.ssh/known_hosts 2>/dev/null || true
- name: Sync project files
run: |
rsync -avz --delete \
-e "ssh -i ~/.ssh/id_deploy -o StrictHostKeyChecking=no" \
--exclude='.git' \
--exclude='node_modules' \
--exclude='dist' \
--exclude='.env*' \
--exclude='firebase-service-account.json' \
--exclude='aether-*-firebase-*' \
--exclude='*.zip' \
--exclude='postgres_data' \
--exclude='redis_data' \
./ root@$MINIS_IP:/root/aether/
- name: Build and restart containers
run: |
ssh -i ~/.ssh/id_deploy -o StrictHostKeyChecking=no root@$MINIS_IP << 'DEPLOY'
cd /root/aether
echo "==> Building containers..."
docker compose up -d --build frontend api worker
echo "==> Cleaning up old images..."
docker image prune -f
echo "==> Deployment complete!"
docker compose ps
DEPLOY