gabriel / musehub public
ci.yml yaml
91 lines 2.9 KB
Raw
sha256:3ff9c9863a9891bdcde71b4a43228f66d0493e38b7cc1d09fe9eb7de774046b2 feat: add repair-commit wire endpoint (API parity with repa… Opus 4.8 minor ⚠ breaking 1 day ago
1 name: CI
2
3 # Trigger on pushes to main and feature branches, and on proposals targeting main.
4 on:
5 push:
6 branches:
7 - main
8 - "feat/*"
9 - "fix/*"
10 - "chore/*"
11 pull_request:
12 branches:
13 - main
14
15 jobs:
16 test:
17 name: Test & typecheck (Python 3.14)
18 container: python:3.14-slim
19 steps:
20 - name: Install dependencies
21 run: pip install -e ".[dev]"
22
23 - name: Static type check
24 run: mypy musehub/
25
26 - name: Run tests
27 run: pytest tests/ -n auto --tb=short
28
29 deploy:
30 name: Deploy to musehub.ai
31 container: python:3.14-slim
32 needs:
33 - test
34 # Only deploy when merging to main (not on proposals or feature branches)
35 if: "trigger == 'push' and branch == 'main'"
36 env:
37 EC2_HOST: ${{ secrets.EC2_HOST }}
38 EC2_USER: ${{ secrets.EC2_USER }}
39 EC2_SSH_KEY: ${{ secrets.EC2_SSH_KEY }}
40 steps:
41 - name: Install deploy tools
42 run: |
43 apt-get update -qq && apt-get install -y --no-install-recommends openssh-client rsync
44
45 - name: Write SSH key
46 run: |
47 mkdir -p ~/.ssh
48 echo "$EC2_SSH_KEY" > ~/.ssh/id_deploy
49 chmod 600 ~/.ssh/id_deploy
50 ssh-keyscan -H "$EC2_HOST" >> ~/.ssh/known_hosts 2>/dev/null
51
52 - name: Rsync code to EC2
53 run: |
54 rsync -az --delete \
55 --exclude='.muse' \
56 --exclude='__pycache__' \
57 --exclude='*.pyc' \
58 --exclude='.env' \
59 --exclude='docker-compose.override.yml' \
60 -e "ssh -i ~/.ssh/id_deploy -o StrictHostKeyChecking=no" \
61 . "$EC2_USER@$EC2_HOST:/opt/musehub/"
62
63 - name: Reload nginx config
64 run: |
65 ssh -i ~/.ssh/id_deploy -o StrictHostKeyChecking=no "$EC2_USER@$EC2_HOST" \
66 "sudo cp /opt/musehub/deploy/nginx-ssl.conf /etc/nginx/sites-available/musehub \
67 && sudo nginx -t && sudo nginx -s reload"
68
69 - name: Rebuild and restart containers
70 run: |
71 ssh -i ~/.ssh/id_deploy -o StrictHostKeyChecking=no "$EC2_USER@$EC2_HOST" \
72 "cd /opt/musehub && docker compose up -d --build"
73
74 - name: Wait for health check
75 run: |
76 ssh -i ~/.ssh/id_deploy -o StrictHostKeyChecking=no "$EC2_USER@$EC2_HOST" \
77 "for i in \$(seq 1 24); do
78 STATUS=\$(docker inspect --format='{{.State.Health.Status}}' musehub 2>/dev/null)
79 echo \"Attempt \$i: \$STATUS\"
80 [ \"\$STATUS\" = 'healthy' ] && exit 0
81 sleep 5
82 done
83 echo 'Container did not become healthy in time'
84 docker logs musehub --tail 30
85 exit 1"
86
87 - name: Smoke test live site
88 run: |
89 CODE=\$(curl -s -o /dev/null -w "%{http_code}" https://musehub.ai/explore)
90 echo "https://musehub.ai/explore → \$CODE"
91 [ "\$CODE" = "200" ] || (echo "Smoke test failed" && exit 1)
File History 1 commit
sha256:3ff9c9863a9891bdcde71b4a43228f66d0493e38b7cc1d09fe9eb7de774046b2 feat: add repair-commit wire endpoint (API parity with repa… Opus 4.8 minor 1 day ago