Files
matrix-ai-agent/.gitea/workflows/deploy.yml
Christian Gick f57c91589f
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 3m44s
fix: Setup SSH before checkout for submodule clone
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 10:40:26 +02:00

40 lines
1.5 KiB
YAML

name: Build & Deploy
on:
push:
branches: [main]
paths-ignore: ['**.md', 'docs/**']
env:
REGISTRY: gitea.agiliton.internal:3000
IMAGE: gitea.agiliton.internal:3000/christian/matrix-ai-agent
TARGET_VM: matrix.agiliton.internal
DEPLOY_PATH: /opt/matrix-ai-agent
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Setup SSH
run: |
mkdir -p ~/.ssh && chmod 700 ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
ssh-keyscan -p 2222 gitea-ssh.agiliton.internal >> ~/.ssh/known_hosts 2>/dev/null || true
ssh-keyscan -H ${{ env.TARGET_VM }} >> ~/.ssh/known_hosts 2>/dev/null || true
- uses: actions/checkout@v4
with:
submodules: true
- name: Login & Build & Push
run: |
echo "${{ secrets.REGISTRY_TOKEN }}" | docker login ${{ env.REGISTRY }} -u christian --password-stdin
DOCKER_BUILDKIT=1 docker build --pull -t ${{ env.IMAGE }}:latest .
docker push ${{ env.IMAGE }}:latest
- name: Deploy
run: |
ssh root@${{ env.TARGET_VM }} << 'EOF'
cd ${{ env.DEPLOY_PATH }} && git pull origin main --ff-only 2>/dev/null || true
docker pull ${{ env.IMAGE }}:latest
docker compose up -d --force-recreate --remove-orphans
EOF
- name: Cleanup
if: always()
run: docker builder prune -f --filter "until=24h" 2>/dev/null || true