-
Notifications
You must be signed in to change notification settings - Fork 1
114 lines (98 loc) · 3.26 KB
/
ci.yml
File metadata and controls
114 lines (98 loc) · 3.26 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
name: CI
on:
push:
branches: [main]
tags:
- 'v*'
pull_request:
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: false
- name: Setup uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
- name: Install dependencies (including dev)
run: uv sync --all-extras
- name: Run linting
run: uv run ruff check .
- name: Run type checking
run: uv run mypy src/
continue-on-error: true # Don't fail on type errors yet
- name: Run tests
run: uv run pytest tests/ -v
continue-on-error: true # Don't fail on test errors yet (no tests written)
docker:
needs: [test]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=ref,event=tag
type=sha,prefix=main-,enable={{is_default_branch}}
type=raw,value=latest,enable={{is_default_branch}}
type=sha
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
deploy:
needs: [test, docker]
# if: github.ref == 'refs/heads/main' && github.event_name == 'push'
if: false # Deployment disabled
runs-on: ubuntu-latest
steps:
- name: Deploy to production server
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
SSH_HOST: 91.99.186.83
SSH_USER: devops
run: |
# Setup SSH
mkdir -p ~/.ssh
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -H $SSH_HOST >> ~/.ssh/known_hosts
# Deploy via SSH
ssh -o StrictHostKeyChecking=no $SSH_USER@$SSH_HOST << 'ENDSSH'
set -e
cd /opt/canton-mcp-server || cd ~/canton-mcp-server
echo "📦 Pulling latest code..."
# Stash any local changes and force sync with main
git fetch origin
git stash || true
git reset --hard origin/main
echo "🐋 Rebuilding and restarting containers..."
docker compose down
docker compose up -d --build
echo "✅ Deployment complete!"
docker compose ps
ENDSSH