62 lines
1.8 KiB
YAML
62 lines
1.8 KiB
YAML
name: Build and Deploy
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
build-and-deploy:
|
|
runs-on: self-hosted
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '22'
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Build TypeScript
|
|
run: npm run build
|
|
env:
|
|
NODE_OPTIONS: --max-old-space-size=12288
|
|
|
|
- name: Log in to GitHub Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: |
|
|
ghcr.io/${{ github.repository }}:latest
|
|
ghcr.io/${{ github.repository }}:${{ github.sha }}
|
|
|
|
- name: Deploy to Hetzner VM
|
|
run: |
|
|
echo "${{ secrets.HETZNER_SSH_KEY }}" > /tmp/deploy_key
|
|
chmod 600 /tmp/deploy_key
|
|
ssh -i /tmp/deploy_key -o StrictHostKeyChecking=no \
|
|
${{ secrets.HETZNER_USER }}@${{ secrets.HETZNER_HOST }} \
|
|
"echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin && \
|
|
docker pull ghcr.io/${{ github.repository }}:${{ github.sha }} && \
|
|
docker stop vector-mcp || true && \
|
|
docker rm vector-mcp || true && \
|
|
docker run -d \
|
|
--name vector-mcp \
|
|
--restart unless-stopped \
|
|
-p 3000:3000 \
|
|
--env-file /etc/vector-mcp/env \
|
|
ghcr.io/${{ github.repository }}:${{ github.sha }}"
|
|
rm /tmp/deploy_key
|