Files
cannamanage/.gitea/workflows/deploy.yml
T
Patrick Plate 6f5e886bd6
Deploy to TrueNAS / deploy (push) Failing after 38s
fix: CI — run tests in Docker containers (runner has no JDK/Node)
2026-06-18 16:11:32 +02:00

107 lines
3.4 KiB
YAML

name: Deploy to TrueNAS
# Auto-deploy on push to main.
# Runs on the self-hosted Gitea Actions runner on TrueNAS.local
# (container: cannamanage-act-runner). The runner mounts the host Docker
# socket into the job container, so `docker compose` commands act on the
# TrueNAS Docker daemon and (re)build/restart the live cannamanage stack.
#
# The job checks the repo out into its own workspace and builds from there,
# so it always deploys exactly the pushed commit — it does NOT depend on the
# old /mnt/VM_SSD_Pool/cannamanage host checkout.
#
# Compose project name is pinned to "cannamanage" so it updates the existing
# containers and reuses the persistent "cannamanage_pgdata" volume on the host.
# Live ports: backend 8081->8080, frontend 3000, db 5432
on:
push:
branches: [main]
# Avoid overlapping deploys if pushes land in quick succession.
concurrency:
group: truenas-deploy
cancel-in-progress: false
jobs:
deploy:
runs-on: ubuntu-latest
env:
COMPOSE: docker compose -f docker-compose.yml -f docker-compose.truenas.yml -p cannamanage
steps:
- name: Check out pushed commit
uses: actions/checkout@v4
- name: Show toolchain
run: |
set -euo pipefail
docker version --format 'docker {{.Server.Version}}'
docker compose version
- name: Run backend tests
run: |
set -euo pipefail
docker run --rm \
-v "$(pwd)":/workspace \
-w /workspace \
maven:3.9-eclipse-temurin-17 \
mvn test --batch-mode -f pom.xml
- name: Frontend lint check
run: |
set -euo pipefail
docker run --rm \
-v "$(pwd)/cannamanage-frontend":/app \
-w /app \
node:22-slim \
sh -c "corepack enable && corepack prepare pnpm@10.8.1 --activate && pnpm install --frozen-lockfile && pnpm run lint"
- name: Build images
run: |
set -euo pipefail
$COMPOSE build
- name: Roll out stack
run: |
set -euo pipefail
$COMPOSE up -d --remove-orphans
- name: Wait for backend health
run: |
set -euo pipefail
echo "Waiting for backend health on :8081 ..."
for i in $(seq 1 20); do
if wget -q -O /dev/null http://192.168.188.119:8081/actuator/health; then
echo "✅ Backend healthy after ${i} attempt(s)"
exit 0
fi
echo " attempt $i/20 — waiting 6s"
sleep 6
done
echo "❌ Backend did not become healthy — recent logs:"
$COMPOSE logs --tail=40 backend
exit 1
- name: Verify frontend
run: |
for i in $(seq 1 10); do
if wget -q -O /dev/null http://192.168.188.119:3000; then
echo "✅ Frontend responding on :3000"
exit 0
fi
echo " attempt $i/10 — waiting 5s"
sleep 5
done
echo "❌ Frontend did not respond"
exit 1
- name: Prune dangling images
run: docker image prune -f || true
- name: Deployment summary
run: |
echo "=== CannaManage deployed to TrueNAS ==="
echo "Commit: ${GITHUB_SHA}"
echo "Backend: http://192.168.188.119:8081"
echo "Frontend: http://192.168.188.119:3000"