Some checks failed
Build & Deploy / build-and-deploy (push) Failing after 1m26s
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
37 lines
1.3 KiB
YAML
37 lines
1.3 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:
|
|
- uses: actions/checkout@v4
|
|
- 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 -H ${{ env.TARGET_VM }} >> ~/.ssh/known_hosts 2>/dev/null || 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
|