Repository navigation
85 lines (71 loc) · 3.12 KB
/
Copy pathdeploy.yml
File metadata and controls
85 lines (71 loc) · 3.12 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
name: Deploy Stack to VPS
on:
push:
branches: [ "main" ]
workflow_dispatch:
concurrency:
group: production-deploy
cancel-in-progress: false
jobs:
ci:
name: Run Quality Gate
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- name: Full Quality Gate
run: npm run check
deploy:
name: Deploy Stack to Target Host
needs: ci
runs-on: ubuntu-latest
if: needs.ci.result == 'success'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Deploy via SSH Key (Ed25519)
uses: appleboy/ssh-action@v1.2.0
with:
host: ${{ secrets.VPS_HOST }}
username: ${{ secrets.VPS_USER }}
key: ${{ secrets.VPS_SSH_KEY }}
port: 22
script_stop: true
script: |
set -e
DEPLOY_PATH="/opt/devops-stack"
echo "==> Wdrazanie aktualizacji w ${DEPLOY_PATH}..."
if [ ! -d "${DEPLOY_PATH}" ]; then
echo "BLAD: Katalog ${DEPLOY_PATH} nie istnieje na serwerze docelowym."
exit 1
fi
cd "${DEPLOY_PATH}"
git fetch origin main
git reset --hard origin/main
chmod +x scripts/*.sh scripts/*.py 2>/dev/null || true
chmod 640 "${DEPLOY_PATH}"/compose/*.yml 2>/dev/null || true
chmod 644 "${DEPLOY_PATH}"/services/ai-router/data/* 2>/dev/null || true
chmod 750 "${DEPLOY_PATH}"/services/ai-router/storage 2>/dev/null || true
bash "${DEPLOY_PATH}/scripts/setup-audit-timer.sh" >/dev/null 2>&1 || true
bash "${DEPLOY_PATH}/scripts/setup-backup-timer.sh" >/dev/null 2>&1 || true
cd compose
(
flock -w 180 9 || { echo "BLAD: Timeout blokady wdrozeniowej /tmp/devops-stack-deploy.lock"; exit 1; }
docker compose --env-file "${DEPLOY_PATH}/.env" -f extensions.yml pull -q cloudflared || true
docker compose --env-file "${DEPLOY_PATH}/.env" -f docker-compose.yml -f extensions.yml -f runners.yml up -d --build --remove-orphans
docker kill -s HUP prometheus >/dev/null 2>&1 || true
) 9>/tmp/devops-stack-deploy.lock
# Automatyczny Garbage Collector po wdrożeniu: usunięcie osieroconych warstw <none> i starego build cache'u (>7 dni)
docker image prune -f >/dev/null 2>&1 || true
docker builder prune --filter "until=168h" -f >/dev/null 2>&1 || true
# Odświeżenie pamięci podręcznej DNS (nscd) w Uptime Kuma po przebudowie kontenera ai-router
docker exec uptime-kuma nscd -i hosts >/dev/null 2>&1 || true
# Idempotentne rozgrzanie pamięci podręcznej RAG (Quick Prompts) po aktualizacji bazy wiedzy
bash "${DEPLOY_PATH}/scripts/warm-ai-cache.sh" || true
echo "==> Wdrozenie zakonczone pomyslnie. Uruchamianie audytu powykonawczego..."
sleep 5
NO_COLOR=1 bash "${DEPLOY_PATH}/scripts/audit-server.sh"