Harden webhook and health checks

This commit is contained in:
Administrator
2025-12-26 13:17:19 +01:00
parent 69a28b0537
commit 152f507d9a
6 changed files with 736 additions and 2 deletions

38
webhook/start.sh Executable file
View File

@@ -0,0 +1,38 @@
#!/bin/bash
# Start the webhook service
# This runs on the host (not in a container) to execute deploy scripts
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
# Ensure Go is available in non-interactive environments (systemd)
GO_CMD="$(command -v go || true)"
if [ -z "$GO_CMD" ] && [ -x /usr/local/go/bin/go ]; then
GO_CMD="/usr/local/go/bin/go"
fi
if [ -z "$GO_CMD" ]; then
echo "Go not found in PATH and /usr/local/go/bin/go is missing" >&2
exit 1
fi
# Build if needed
if [ ! -f webhook-service ] || [ main.go -nt webhook-service ]; then
echo "Building webhook service..."
"$GO_CMD" build -o webhook-service main.go || exit 1
fi
# Load environment from .env if exists
if [ -f .env ]; then
export $(grep -v '^#' .env | xargs)
fi
# Default config
export WEBHOOK_PORT="${WEBHOOK_PORT:-9090}"
export WEBHOOK_TEST_COPPERTONE_TECH_BRANCH="${WEBHOOK_TEST_COPPERTONE_TECH_BRANCH:-testing}"
export WEBHOOK_CHUCKIE_COPPERTONE_TECH_BRANCH="${WEBHOOK_CHUCKIE_COPPERTONE_TECH_BRANCH:-main}"
export WEBHOOK_DEV_COPPERTONE_TECH_BRANCH="${WEBHOOK_DEV_COPPERTONE_TECH_BRANCH:-develop}"
export WEBHOOK_GAMES_COPPERTONE_TECH_BRANCH="${WEBHOOK_GAMES_COPPERTONE_TECH_BRANCH:-main}"
export WEBHOOK_COPPERTONE_TECH_BRANCH="${WEBHOOK_COPPERTONE_TECH_BRANCH:-main}"
echo "Starting webhook service on port $WEBHOOK_PORT..."
exec ./webhook-service