#!/bin/bash # git-push-schemas: Push to git AND sync schemas to production # # Usage: ./infrastructure/git-push-schemas.sh [git push args] # # This script: # 1. Pushes to Forgejo (git push origin master) # 2. Rsyncs schemas directly to Hetzner server (bypasses slow Forgejo→Hetzner network) # 3. Triggers webhook to copy staging → frontend set -e SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" # Colors GREEN='\033[0;32m' BLUE='\033[0;34m' YELLOW='\033[1;33m' NC='\033[0m' echo -e "${BLUE}════════════════════════════════════════════════════════════════${NC}" echo -e "${BLUE} GLAM Schema Push${NC}" echo -e "${BLUE}════════════════════════════════════════════════════════════════${NC}" # Step 1: Git push echo -e "\n${YELLOW}Step 1: Pushing to Forgejo...${NC}" git push "$@" echo -e "${GREEN}✓ Git push complete${NC}" # Step 2: Check if schemas changed CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD 2>/dev/null || git diff --name-only HEAD) if echo "$CHANGED_FILES" | grep -q "^schemas/20251121/linkml/"; then echo -e "\n${YELLOW}Step 2: Syncing schemas to server...${NC}" # Direct rsync to server (fast: bypasses Forgejo→Hetzner slow link) rsync -az --delete \ --exclude "*.pyc" \ --exclude "__pycache__" \ -e "ssh -o StrictHostKeyChecking=no" \ "$PROJECT_ROOT/schemas/20251121/linkml/" \ "root@91.98.224.44:/var/lib/glam/repo/schemas/20251121/linkml/" echo -e "${GREEN}✓ Schemas synced to staging${NC}" # Step 3: Trigger local copy on server (staging → frontend) echo -e "\n${YELLOW}Step 3: Deploying to frontend...${NC}" # Direct rsync to frontend (even simpler - skip webhook) rsync -az --delete \ --exclude "*.pyc" \ --exclude "__pycache__" \ -e "ssh -o StrictHostKeyChecking=no" \ "$PROJECT_ROOT/schemas/20251121/linkml/" \ "root@91.98.224.44:/var/www/glam-frontend/schemas/20251121/linkml/" echo -e "${GREEN}✓ Schemas deployed to frontend${NC}" else echo -e "\n${YELLOW}No schema changes detected, skipping sync${NC}" fi echo -e "\n${BLUE}════════════════════════════════════════════════════════════════${NC}" echo -e "${GREEN} Done! Schemas available at:${NC}" echo -e " https://bronhouder.nl/schemas/20251121/linkml/" echo -e "${BLUE}════════════════════════════════════════════════════════════════${NC}"