-
Notifications
You must be signed in to change notification settings - Fork 0
48 lines (40 loc) · 1.23 KB
/
deploy.yml
File metadata and controls
48 lines (40 loc) · 1.23 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
name: Deploy Production
on:
workflow_run:
workflows: ["CI"]
branches: [main]
types:
- completed
jobs:
deploy:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- name: Deploy to VPS
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.VPS_HOST }}
username: ${{ secrets.VPS_USER }}
key: ${{ secrets.VPS_SSH_KEY }}
port: ${{ secrets.VPS_PORT }}
script: |
set -e
cd ~/Hs_codes_api
echo "Pulling latest code..."
git fetch origin main
git reset --hard origin/main
echo "Building and starting containers..."
docker compose up -d --build
echo "Waiting for application to start..."
sleep 20
echo "Checking health endpoint..."
for i in $(seq 1 20); do
if curl -fsS http://localhost:8001/api/v1/health/ > /dev/null; then
echo "Health check passed"
exit 0
fi
echo "Attempt $i/20 - waiting..."
sleep 5
done
echo "Health check failed after 100s"
exit 1