-
Notifications
You must be signed in to change notification settings - Fork 0
97 lines (80 loc) · 2.79 KB
/
Copy pathdeploy.yml
File metadata and controls
97 lines (80 loc) · 2.79 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
name: Deploy
on:
workflow_dispatch:
concurrency:
group: deploy
cancel-in-progress: false
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
app: [control-plane, worker]
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Resolve Dockerfile
id: dockerfile
run: |
APP=${{ matrix.app }}
if [ "$APP" = "control-plane" ] && [ -f "Dockerfile.control-plane" ]; then
echo "path=Dockerfile.control-plane" >> $GITHUB_OUTPUT
else
echo "path=apps/${APP}/Dockerfile" >> $GITHUB_OUTPUT
fi
- uses: docker/setup-qemu-action@v3
- uses: docker/build-push-action@v6
with:
context: .
file: ${{ steps.dockerfile.outputs.path }}
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/paws-${{ matrix.app }}:${{ github.sha }}
ghcr.io/${{ github.repository_owner }}/paws-${{ matrix.app }}:latest
cache-from: type=gha
cache-to: type=gha,mode=max
deploy:
needs: [build-and-push]
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: tailscale/github-action@v3
with:
authkey: ${{ secrets.TS_AUTHKEY }}
- name: Wait for Tailscale tunnel
run: |
echo "==> Waiting for Tailscale tunnel to establish..."
for i in $(seq 1 30); do
if sudo tailscale ping -c 1 100.78.44.23 2>/dev/null; then
echo "==> Tailscale tunnel ready"
break
fi
echo " Attempt $i/30..."
sleep 2
done
- name: Deploy to server
run: |
# Tailscale SSH handles auth via ACL (tag:ci -> tag:servers)
# No SSH key needed — identity is the Tailscale node
SSH="ssh -o StrictHostKeyChecking=accept-new -o ConnectTimeout=10 root@100.78.44.23"
echo "==> Pulling latest code..."
$SSH "cd /opt/paws && git fetch origin main && git reset --hard origin/main"
echo "==> Installing dependencies..."
$SSH "cd /opt/paws && bun install"
echo "==> Restarting services..."
$SSH "systemctl restart paws-control-plane paws-worker"
echo "==> Waiting for services to start..."
sleep 5
echo "==> Health check..."
$SSH "curl -sf http://127.0.0.1:4000/health && echo '' && curl -sf http://127.0.0.1:3000/health"
echo "==> Deploy complete!"