Files
Momento/.gitea/workflows/deploy.yaml
sepehr 3944f699bd
Some checks failed
Deploy to Production / Build and Deploy (push) Failing after 3m51s
ci: fix git safe.directory for /opt/memento
Made-with: Cursor
2026-04-25 21:16:22 +02:00

57 lines
1.6 KiB
YAML

name: Deploy to Production
on:
push:
branches:
- main
jobs:
deploy:
name: Build and Deploy
runs-on: ubuntu-24.04
steps:
- name: Setup SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -H 192.168.1.190 >> ~/.ssh/known_hosts
- name: Deploy via SSH
run: |
ssh root@192.168.1.190 << 'ENDSSH'
set -e
cd /opt/memento
echo "=== Git pull ==="
git config --global --add safe.directory /opt/memento
git pull origin main
echo "=== Building ==="
docker compose build memento-note
echo "=== Starting ==="
docker compose up -d --remove-orphans
docker compose ps
ENDSSH
- name: Wait for app to be healthy
run: |
echo "Waiting up to 120s for memento-web..."
for i in $(seq 1 24); do
STATUS=$(ssh root@192.168.1.190 "docker inspect --format='{{.State.Health.Status}}' memento-web 2>/dev/null || echo unknown")
if [ "$STATUS" = "healthy" ]; then
echo "OK - healthy after $((i * 5))s"
exit 0
fi
echo " [$((i * 5))s] $STATUS"
sleep 5
done
echo "Timeout! Derniers logs :"
ssh root@192.168.1.190 "docker logs memento-web --tail=30"
exit 1
- name: Cleanup
if: always()
run: ssh root@192.168.1.190 "docker image prune -f" || true