managarten/.github/workflows/cd-macmini.yml
Till JS 819568c3df feat(infra): consolidate 21 Matrix bots into Go binary + add Go API gateway
Replace 21 separate NestJS Matrix bot processes (~2.1 GB RAM, ~4.2 GB Docker images)
with a single Go binary using plugin architecture (8.6 MB binary, ~30 MB RAM).

New services:
- services/mana-matrix-bot/ — Go Matrix bot with 21 plugins (mautrix-go, Redis sessions)
- services/mana-api-gateway-go/ — Go API gateway (rate limiting, API keys, credit billing)

Deleted:
- 21 services/matrix-*-bot/ directories
- packages/bot-services/ and packages/matrix-bot-common/
- Legacy deploy scripts and CI build jobs

Updated:
- docker-compose.macmini.yml: new Go services, legacy bots removed
- CI/CD: change detection + build jobs for Go services
- Root package.json: new dev:matrix, build:matrix, test:matrix scripts

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:03:00 +01:00

559 lines
24 KiB
YAML

# CD Pipeline: Auto-deploy to Mac Mini on push to main
#
# Requires a self-hosted GitHub Actions runner on the Mac Mini.
# Setup: see docs/MAC_MINI_RUNNER_SETUP.md
#
# Flow:
# Push → main : Detects changed services → rebuilds & restarts only those containers
#
# The runner executes directly on the Mac Mini, so it has access to
# Docker, docker-compose, and the local project directory.
name: CD Mac Mini
on:
push:
branches:
- main
workflow_dispatch:
inputs:
service:
description: 'Service to deploy (or "all" for everything)'
required: false
default: 'all'
type: choice
options:
- all
- matrix-web
- mana-core-auth
- chat-backend
- chat-web
- todo-backend
- todo-web
- calendar-backend
- calendar-web
- clock-backend
- clock-web
- contacts-backend
- contacts-web
- mukke-backend
- mukke-web
- storage-backend
- storage-web
- mana-matrix-bot
concurrency:
group: cd-macmini
cancel-in-progress: false # Don't cancel in-progress deploys
env:
PROJECT_DIR: /Users/mana/projects/manacore-monorepo
COMPOSE_FILE: docker-compose.macmini.yml
ENV_FILE: .env.macmini
DEPLOY_NOTIFY_ROOM_ID: ${{ secrets.DEPLOY_NOTIFY_ROOM_ID }}
DEPLOY_NOTIFY_BOT_TOKEN: ${{ secrets.DEPLOY_NOTIFY_BOT_TOKEN }}
DOCKER_BUILDKIT: 1
PATH: /usr/local/bin:/opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin
jobs:
# ===========================================
# Detect what changed
# ===========================================
detect-changes:
name: Detect Changes
runs-on: self-hosted
if: github.event_name == 'push'
outputs:
matrix-web: ${{ steps.changes.outputs.matrix-web }}
mana-core-auth: ${{ steps.changes.outputs.mana-core-auth }}
chat-backend: ${{ steps.changes.outputs.chat-backend }}
chat-web: ${{ steps.changes.outputs.chat-web }}
todo-backend: ${{ steps.changes.outputs.todo-backend }}
todo-web: ${{ steps.changes.outputs.todo-web }}
calendar-backend: ${{ steps.changes.outputs.calendar-backend }}
calendar-web: ${{ steps.changes.outputs.calendar-web }}
clock-backend: ${{ steps.changes.outputs.clock-backend }}
clock-web: ${{ steps.changes.outputs.clock-web }}
contacts-backend: ${{ steps.changes.outputs.contacts-backend }}
contacts-web: ${{ steps.changes.outputs.contacts-web }}
mukke-backend: ${{ steps.changes.outputs.mukke-backend }}
mukke-web: ${{ steps.changes.outputs.mukke-web }}
storage-backend: ${{ steps.changes.outputs.storage-backend }}
storage-web: ${{ steps.changes.outputs.storage-web }}
mana-matrix-bot: ${{ steps.changes.outputs.mana-matrix-bot }}
any-changes: ${{ steps.changes.outputs.any-changes }}
steps:
- name: Check for changes
id: changes
run: |
cd "${{ env.PROJECT_DIR }}"
# Get changed files between previous and current commit
CHANGED=$(git diff --name-only HEAD~1 HEAD 2>/dev/null || echo "")
# Shared packages trigger rebuilds for all services that use them
SHARED_CHANGED="false"
if echo "$CHANGED" | grep -qE "^packages/(shared-ui|shared-theme|shared-icons|shared-tailwind|shared-auth|shared-branding|shared-i18n|shared-utils|shared-types)/"; then
SHARED_CHANGED="true"
fi
check_changes() {
local name=$1
shift
local result="false"
for path in "$@"; do
if echo "$CHANGED" | grep -q "^$path"; then
result="true"
break
fi
done
# Shared package changes trigger rebuild
if [ "$SHARED_CHANGED" == "true" ]; then
result="true"
fi
echo "$name=$result" >> $GITHUB_OUTPUT
echo " $name: $result"
}
echo "Changed files:"
echo "$CHANGED" | head -20
echo ""
echo "Shared packages changed: $SHARED_CHANGED"
echo ""
check_changes "matrix-web" "apps/matrix/apps/web/" "apps/matrix/packages/"
check_changes "mana-core-auth" "services/mana-core-auth/"
check_changes "chat-backend" "apps/chat/apps/backend/" "apps/chat/packages/"
check_changes "chat-web" "apps/chat/apps/web/" "apps/chat/packages/"
check_changes "todo-backend" "apps/todo/apps/backend/" "apps/todo/packages/"
check_changes "todo-web" "apps/todo/apps/web/" "apps/todo/packages/"
check_changes "calendar-backend" "apps/calendar/apps/backend/" "apps/calendar/packages/"
check_changes "calendar-web" "apps/calendar/apps/web/" "apps/calendar/packages/"
check_changes "clock-backend" "apps/clock/apps/backend/" "apps/clock/packages/"
check_changes "clock-web" "apps/clock/apps/web/" "apps/clock/packages/"
check_changes "contacts-backend" "apps/contacts/apps/backend/" "apps/contacts/packages/"
check_changes "contacts-web" "apps/contacts/apps/web/" "apps/contacts/packages/"
check_changes "mukke-backend" "apps/mukke/apps/backend/" "apps/mukke/packages/"
check_changes "mukke-web" "apps/mukke/apps/web/" "apps/mukke/packages/"
check_changes "storage-backend" "apps/storage/apps/backend/" "apps/storage/packages/"
check_changes "storage-web" "apps/storage/apps/web/" "apps/storage/packages/"
check_changes "mana-matrix-bot" "services/mana-matrix-bot/"
check_changes "mana-landing-builder" "services/mana-landing-builder/" "packages/shared-types/" "packages/shared-landing-ui/"
# Check if anything needs deploying
ANY="false"
for svc in matrix-web mana-core-auth chat-backend chat-web todo-backend todo-web calendar-backend calendar-web clock-backend clock-web contacts-backend contacts-web mukke-backend mukke-web storage-backend storage-web mana-matrix-bot mana-landing-builder; do
val=$(grep "^$svc=" $GITHUB_OUTPUT | tail -1 | cut -d= -f2)
if [ "$val" == "true" ]; then
ANY="true"
break
fi
done
echo "any-changes=$ANY" >> $GITHUB_OUTPUT
# ===========================================
# Deploy changed services
# ===========================================
deploy:
name: Deploy
runs-on: self-hosted
needs: [detect-changes]
if: |
always() &&
(needs.detect-changes.result == 'success' && needs.detect-changes.outputs.any-changes == 'true') ||
github.event_name == 'workflow_dispatch'
steps:
- name: Pull latest code
run: |
cd "${{ env.PROJECT_DIR }}"
git pull origin main
- name: Init deploy tracking
id: init
run: |
cd "${{ env.PROJECT_DIR }}"
source scripts/deploy-metrics.sh
deploy_timer_start
echo "start_epoch=$DEPLOY_START_EPOCH" >> $GITHUB_OUTPUT
ensure_deploy_schema
- name: Ensure env vars exist
run: |
cd "${{ env.PROJECT_DIR }}"
# Add CALENDAR_ENCRYPTION_KEY if not present
if ! grep -q "CALENDAR_ENCRYPTION_KEY" "${{ env.ENV_FILE }}" 2>/dev/null; then
echo "CALENDAR_ENCRYPTION_KEY=$(openssl rand -base64 32)" >> "${{ env.ENV_FILE }}"
echo "Added CALENDAR_ENCRYPTION_KEY to ${{ env.ENV_FILE }}"
fi
- name: Determine services to deploy
id: services
run: |
cd "${{ env.PROJECT_DIR }}"
SERVICES=""
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
INPUT="${{ inputs.service }}"
if [ "$INPUT" == "all" ]; then
echo "Manual deploy: all services"
echo "deploy-all=true" >> $GITHUB_OUTPUT
exit 0
else
SERVICES="$INPUT"
fi
else
# Build list from detected changes
if [ "${{ needs.detect-changes.outputs.matrix-web }}" == "true" ]; then SERVICES="$SERVICES matrix-web"; fi
if [ "${{ needs.detect-changes.outputs.mana-core-auth }}" == "true" ]; then SERVICES="$SERVICES mana-auth"; fi
if [ "${{ needs.detect-changes.outputs.chat-backend }}" == "true" ]; then SERVICES="$SERVICES chat-backend"; fi
if [ "${{ needs.detect-changes.outputs.chat-web }}" == "true" ]; then SERVICES="$SERVICES chat-web"; fi
if [ "${{ needs.detect-changes.outputs.todo-backend }}" == "true" ]; then SERVICES="$SERVICES todo-backend"; fi
if [ "${{ needs.detect-changes.outputs.todo-web }}" == "true" ]; then SERVICES="$SERVICES todo-web"; fi
if [ "${{ needs.detect-changes.outputs.calendar-backend }}" == "true" ]; then SERVICES="$SERVICES calendar-backend"; fi
if [ "${{ needs.detect-changes.outputs.calendar-web }}" == "true" ]; then SERVICES="$SERVICES calendar-web"; fi
if [ "${{ needs.detect-changes.outputs.clock-backend }}" == "true" ]; then SERVICES="$SERVICES clock-backend"; fi
if [ "${{ needs.detect-changes.outputs.clock-web }}" == "true" ]; then SERVICES="$SERVICES clock-web"; fi
if [ "${{ needs.detect-changes.outputs.contacts-backend }}" == "true" ]; then SERVICES="$SERVICES contacts-backend"; fi
if [ "${{ needs.detect-changes.outputs.contacts-web }}" == "true" ]; then SERVICES="$SERVICES contacts-web"; fi
if [ "${{ needs.detect-changes.outputs.mukke-backend }}" == "true" ]; then SERVICES="$SERVICES mukke-backend"; fi
if [ "${{ needs.detect-changes.outputs.mukke-web }}" == "true" ]; then SERVICES="$SERVICES mukke-web"; fi
if [ "${{ needs.detect-changes.outputs.storage-backend }}" == "true" ]; then SERVICES="$SERVICES storage-backend"; fi
if [ "${{ needs.detect-changes.outputs.storage-web }}" == "true" ]; then SERVICES="$SERVICES storage-web"; fi
if [ "${{ needs.detect-changes.outputs.mana-matrix-bot }}" == "true" ]; then SERVICES="$SERVICES mana-matrix-bot"; fi
if [ "${{ needs.detect-changes.outputs.mana-landing-builder }}" == "true" ]; then SERVICES="$SERVICES mana-landing-builder"; fi
fi
echo "services=$SERVICES" >> $GITHUB_OUTPUT
echo "deploy-all=false" >> $GITHUB_OUTPUT
echo "Services to deploy: $SERVICES"
- name: Build shared base image
run: |
cd "${{ env.PROJECT_DIR }}"
SERVICES="${{ steps.services.outputs.services }}"
DEPLOY_ALL="${{ steps.services.outputs.deploy-all }}"
# Check if any backend service is being deployed
NEEDS_BASE=false
if [ "$DEPLOY_ALL" == "true" ]; then
NEEDS_BASE=true
else
for svc in $SERVICES; do
case "$svc" in *-backend) NEEDS_BASE=true; break ;; esac
done
fi
NEEDS_WEB_BASE=false
if [ "$DEPLOY_ALL" == "true" ]; then
NEEDS_WEB_BASE=true
else
for svc in $SERVICES; do
case "$svc" in *-web) NEEDS_WEB_BASE=true; break ;; esac
done
fi
if [ "$NEEDS_BASE" == "true" ]; then
echo "=== Building shared NestJS base image ==="
docker build -f docker/Dockerfile.nestjs-base -t nestjs-base:local . 2>&1 | tail -5
echo "NestJS base image built"
else
echo "No backends to deploy, skipping NestJS base image"
fi
if [ "$NEEDS_WEB_BASE" == "true" ]; then
echo "=== Building shared SvelteKit base image ==="
docker build -f docker/Dockerfile.sveltekit-base -t sveltekit-base:local . 2>&1 | tail -5
echo "SvelteKit base image built"
else
echo "No web apps to deploy, skipping SvelteKit base image"
fi
- name: Build and deploy services
id: build
run: |
cd "${{ env.PROJECT_DIR }}"
source scripts/deploy-metrics.sh
DEPLOY_ALL="${{ steps.services.outputs.deploy-all }}"
SERVICES="${{ steps.services.outputs.services }}"
# Determine final service list
if [ "$DEPLOY_ALL" == "true" ]; then
# Get all service names from compose file
SERVICES=$(docker compose -f "$COMPOSE_FILE" --env-file "$ENV_FILE" config --services | tr '\n' ' ')
echo "=== Rebuilding ALL services ==="
elif [ -z "$SERVICES" ]; then
echo "No services to deploy"
echo "build-times=" >> $GITHUB_OUTPUT
exit 0
else
echo "=== Rebuilding: $SERVICES ==="
fi
# Build each service individually to capture build times
BUILD_TIMES=""
for svc in $SERVICES; do
echo "--- Building $svc ---"
build_start=$(date +%s)
docker compose -f "$COMPOSE_FILE" --env-file "$ENV_FILE" build "$svc" 2>&1 || true
build_end=$(date +%s)
build_dur=$(( build_end - build_start ))
BUILD_TIMES="$BUILD_TIMES $svc:$build_dur"
echo " $svc built in ${build_dur}s"
done
# Start all services at once (no rebuild, images already built)
echo "=== Starting services ==="
if [ "$DEPLOY_ALL" == "true" ]; then
docker compose -f "$COMPOSE_FILE" --env-file "$ENV_FILE" up -d
else
docker compose -f "$COMPOSE_FILE" --env-file "$ENV_FILE" up -d --no-deps $SERVICES
fi
echo "=== Waiting for services to start ==="
sleep 10
echo "build-times=$BUILD_TIMES" >> $GITHUB_OUTPUT
- name: Health checks
id: health
run: |
cd "${{ env.PROJECT_DIR }}"
source scripts/deploy-metrics.sh
# Service -> health URL mapping
health_url_for() {
case "$1" in
mana-auth) echo "http://localhost:3001/health" ;;
matrix-web) echo "http://localhost:5180/health" ;;
chat-backend) echo "http://localhost:3030/health" ;;
chat-web) echo "http://localhost:5010/health" ;;
todo-backend) echo "http://localhost:3031/health" ;;
todo-web) echo "http://localhost:5011/health" ;;
calendar-backend) echo "http://localhost:3032/health" ;;
calendar-web) echo "http://localhost:5012/health" ;;
clock-backend) echo "http://localhost:3033/health" ;;
clock-web) echo "http://localhost:5013/health" ;;
contacts-backend) echo "http://localhost:3034/health" ;;
contacts-web) echo "http://localhost:5014/health" ;;
mukke-backend) echo "http://localhost:3010/health" ;;
mukke-web) echo "http://localhost:5180/health" ;;
storage-backend) echo "http://localhost:3035/api/v1/health" ;;
storage-web) echo "http://localhost:5015/health" ;;
*) echo "" ;;
esac
}
# Only check services that were actually deployed
DEPLOY_ALL="${{ steps.services.outputs.deploy-all }}"
SERVICES="${{ steps.services.outputs.services }}"
if [ "$DEPLOY_ALL" == "true" ]; then
SERVICES="mana-auth matrix-web chat-backend chat-web todo-backend todo-web calendar-backend calendar-web clock-backend clock-web contacts-backend contacts-web mukke-backend mukke-web storage-backend storage-web"
fi
HEALTH_RESULTS=""
echo "=== Health Checks ==="
for svc in $SERVICES; do
url=$(health_url_for "$svc")
if [ -z "$url" ]; then
echo " - $svc: no health endpoint configured"
HEALTH_RESULTS="$HEALTH_RESULTS $svc:skipped:0:0"
continue
fi
result=$(check_health_timed "$svc" "$url" 2>/dev/null) || true
status=$(echo "$result" | awk '{print $1}')
elapsed=$(echo "$result" | awk '{print $2}')
http_code=$(echo "$result" | awk '{print $3}')
if [ -z "$status" ]; then
status="skipped"
elapsed="0"
http_code="0"
fi
if [ "$status" = "ok" ]; then
echo " ✓ $svc: OK (${elapsed}s)"
else
echo " ✗ $svc: $status (HTTP $http_code, ${elapsed}s)"
fi
HEALTH_RESULTS="$HEALTH_RESULTS $svc:$status:$http_code:$elapsed"
done
echo "health-results=$HEALTH_RESULTS" >> $GITHUB_OUTPUT
- name: Record deploy metrics
if: always()
run: |
cd "${{ env.PROJECT_DIR }}"
source scripts/deploy-metrics.sh
START_EPOCH="${{ steps.init.outputs.start_epoch }}"
NOW=$(date +%s)
DURATION=$(( NOW - START_EPOCH ))
# Determine overall status
STATUS="success"
if [ "${{ job.status }}" != "success" ]; then
STATUS="failure"
fi
# Determine services list
DEPLOY_ALL="${{ steps.services.outputs.deploy-all }}"
SERVICES="${{ steps.services.outputs.services }}"
if [ "$DEPLOY_ALL" == "true" ]; then
SERVICES_CSV="all"
else
SERVICES_CSV=$(echo "$SERVICES" | tr ' ' ',')
fi
COMMIT_MSG=$(git log -1 --pretty=%s 2>/dev/null | head -c 200 || echo "unknown")
BRANCH="${{ github.ref_name }}"
# Insert deployment row
DEPLOY_ID=$(insert_deployment \
"${{ github.run_id }}" \
"${{ github.run_attempt }}" \
"${{ github.sha }}" \
"$COMMIT_MSG" \
"$BRANCH" \
"${{ github.event_name }}" \
"${{ github.actor }}" \
"$SERVICES_CSV" \
"$STATUS" 2>/dev/null) || DEPLOY_ID=""
if [ -n "$DEPLOY_ID" ]; then
# Finalise with duration
finalise_deployment "$DEPLOY_ID" "$STATUS" "$DURATION" 2>/dev/null || true
# Helper: lookup value from "key:val key2:val2" string
# Usage: lookup "key" "key:val key2:val2" [field_index] (default: 2nd field)
lookup() {
local needle="$1" haystack="$2" field="${3:-2}"
for item in $haystack; do
if [ "${item%%:*}" = "$needle" ]; then
echo "$item" | cut -d: -f"$field"
return
fi
done
echo ""
}
BUILD_TIMES="${{ steps.build.outputs.build-times }}"
HEALTH_RESULTS="${{ steps.health.outputs.health-results }}"
# Collect unique service names from both build and health data
ALL_SVCS=$(echo "$BUILD_TIMES $HEALTH_RESULTS" | tr ' ' '\n' | cut -d: -f1 | sort -u | tr '\n' ' ')
for svc in $ALL_SVCS; do
[ -z "$svc" ] && continue
build_dur=$(lookup "$svc" "$BUILD_TIMES" 2)
build_dur="${build_dur:-0}"
img_mb=$(get_image_size_mb "$svc" 2>/dev/null || echo "0")
startup=$(lookup "$svc" "$HEALTH_RESULTS" 4)
startup="${startup:-0}"
health=$(lookup "$svc" "$HEALTH_RESULTS" 2)
health="${health:-skipped}"
http_code=$(lookup "$svc" "$HEALTH_RESULTS" 3)
http_code="${http_code:-0}"
insert_deploy_service "$DEPLOY_ID" "$svc" "$build_dur" "$img_mb" "$startup" "$health" "$http_code" 2>/dev/null || true
push_service_metrics "$svc" "$build_dur" "$img_mb" "$health" 2>/dev/null || true
done
fi
# Push overall metrics to Pushgateway
push_deploy_metrics "$STATUS" "$DURATION" "$BRANCH" 2>/dev/null || true
echo "Deploy tracking recorded: status=$STATUS duration=${DURATION}s"
- name: Notify on failure
if: failure()
run: |
cd "${{ env.PROJECT_DIR }}"
SERVICES="${{ steps.services.outputs.services }}"
[ "${{ steps.services.outputs.deploy-all }}" == "true" ] && SERVICES="all"
COMMIT_MSG=$(git log -1 --pretty=%s 2>/dev/null | head -c 100)
RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
MSG="⚠️ **Deploy failed**\n\n**Services:** ${SERVICES}\n**Commit:** ${COMMIT_MSG}\n**By:** ${{ github.actor }}\n**[View logs](${RUN_URL})**"
# Send to Matrix deploy-notifications room via Synapse API
ROOM_ID="${DEPLOY_NOTIFY_ROOM_ID:-}"
BOT_TOKEN="${DEPLOY_NOTIFY_BOT_TOKEN:-}"
if [ -n "$ROOM_ID" ] && [ -n "$BOT_TOKEN" ]; then
TXN_ID="deploy-$(date +%s)"
curl -s -X PUT \
"http://localhost:8008/_matrix/client/v3/rooms/${ROOM_ID}/send/m.room.message/${TXN_ID}" \
-H "Authorization: Bearer ${BOT_TOKEN}" \
-H "Content-Type: application/json" \
-d "{\"msgtype\":\"m.text\",\"body\":\"Deploy failed: ${SERVICES}\",\"format\":\"org.matrix.custom.html\",\"formatted_body\":\"$(echo -e "$MSG" | sed 's/"/\\"/g')\"}" \
|| true
echo "Matrix notification sent"
else
echo "Matrix notification skipped (DEPLOY_NOTIFY_ROOM_ID or DEPLOY_NOTIFY_BOT_TOKEN not set)"
fi
- name: Cleanup old images
if: always()
run: |
cd "${{ env.PROJECT_DIR }}"
echo "=== Pruning dangling images ==="
docker image prune -f 2>/dev/null || true
echo "=== Pruning unused images older than 7 days ==="
docker image prune -a -f --filter "until=168h" 2>/dev/null || true
- name: Summary
if: always()
run: |
cd "${{ env.PROJECT_DIR }}"
START_EPOCH="${{ steps.init.outputs.start_epoch }}"
NOW=$(date +%s)
DURATION=$(( NOW - START_EPOCH ))
echo "## Deployment Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Trigger:** ${{ github.event_name }}" >> $GITHUB_STEP_SUMMARY
echo "**Commit:** \`${{ github.sha }}\`" >> $GITHUB_STEP_SUMMARY
echo "**Duration:** ${DURATION}s" >> $GITHUB_STEP_SUMMARY
echo "**Status:** ${{ job.status }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ "${{ steps.services.outputs.deploy-all }}" == "true" ]; then
echo "**Services:** All" >> $GITHUB_STEP_SUMMARY
else
echo "**Services:** ${{ steps.services.outputs.services }}" >> $GITHUB_STEP_SUMMARY
fi
# Build times table
BUILD_TIMES="${{ steps.build.outputs.build-times }}"
if [ -n "$BUILD_TIMES" ]; then
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Build Times" >> $GITHUB_STEP_SUMMARY
echo "| Service | Duration |" >> $GITHUB_STEP_SUMMARY
echo "|---------|----------|" >> $GITHUB_STEP_SUMMARY
for entry in $BUILD_TIMES; do
svc="${entry%%:*}"
dur="${entry#*:}"
echo "| $svc | ${dur}s |" >> $GITHUB_STEP_SUMMARY
done
fi
# Health results table
HEALTH_RESULTS="${{ steps.health.outputs.health-results }}"
if [ -n "$HEALTH_RESULTS" ]; then
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Health Checks" >> $GITHUB_STEP_SUMMARY
echo "| Service | Status | HTTP | Startup |" >> $GITHUB_STEP_SUMMARY
echo "|---------|--------|------|---------|" >> $GITHUB_STEP_SUMMARY
for entry in $HEALTH_RESULTS; do
svc=$(echo "$entry" | cut -d: -f1)
h_status=$(echo "$entry" | cut -d: -f2)
h_code=$(echo "$entry" | cut -d: -f3)
h_time=$(echo "$entry" | cut -d: -f4)
icon="✓"
[ "$h_status" != "ok" ] && icon="✗"
echo "| $svc | $icon $h_status | $h_code | ${h_time}s |" >> $GITHUB_STEP_SUMMARY
done
fi