glam/.forgejo/workflows/deploy-frontend.yml
kempersc 0f7fbf1ca0
Some checks are pending
Deploy Frontend / build-and-deploy (push) Waiting to run
feat(ci): add Forgejo Actions workflow for auto-deploy on LinkML schema changes
Infrastructure changes to enable automatic frontend deployment when schemas change:

- Add .forgejo/workflows/deploy-frontend.yml workflow triggered by:
  - Changes to frontend/** or schemas/20251121/linkml/**
  - Manual workflow dispatch

- Rewrite generate-schema-manifest.cjs to properly scan all schema directories
  - Recursively scans classes, enums, slots, modules directories
  - Uses singular category names (class, enum, slot) matching TypeScript types
  - Includes all 4 main schemas at root level
  - Skips archive directories and backup files

- Update schema-loader.ts to match new manifest format
  - Add SchemaCategory interface
  - Update SchemaManifest to use categories as array
  - Add flattenCategories() helper function
  - Add getSchemaCategories() and getSchemaCategoriesSync() functions

The workflow builds frontend with updated manifest and deploys to bronhouder.nl
2026-01-11 14:16:57 +01:00

116 lines
3.7 KiB
YAML

# GLAM Frontend Deployment
# Automatically builds and deploys frontend to bronhouder.nl when changes are pushed
#
# Triggered by:
# - Any changes to frontend/ directory
# - Any changes to schemas/20251121/linkml/ directory (LinkML schema updates)
# - Manual workflow dispatch
#
# This workflow:
# 1. Syncs LinkML schemas to frontend/public
# 2. Regenerates the schema manifest (for LinkML viewer)
# 3. Builds the frontend (Vite/React)
# 4. Deploys to server via rsync
name: Deploy Frontend
on:
push:
branches:
- master
paths:
- 'frontend/**'
- 'schemas/20251121/linkml/**'
- '.forgejo/workflows/deploy-frontend.yml'
# Allow manual trigger
workflow_dispatch:
env:
NODE_VERSION: '20'
SERVER_IP: '91.98.224.44'
SERVER_USER: 'root'
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: Install dependencies
working-directory: frontend
run: npm ci
- name: Sync LinkML schemas to frontend
working-directory: frontend
run: npm run sync-schemas
- name: Generate schema manifest
working-directory: frontend
run: npm run generate-manifest
- name: Build frontend
working-directory: frontend
run: npm run build
env:
VITE_OXIGRAPH_URL: https://bronhouder.nl
- name: Setup SSH key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.DEPLOY_SSH_PRIVATE_KEY }}" > ~/.ssh/deploy_key
chmod 600 ~/.ssh/deploy_key
ssh-keyscan -H ${{ env.SERVER_IP }} >> ~/.ssh/known_hosts 2>/dev/null || true
- name: Deploy frontend to server
run: |
echo "Deploying frontend build to server..."
rsync -avz --progress --delete \
-e "ssh -i ~/.ssh/deploy_key -o StrictHostKeyChecking=no" \
frontend/dist/ \
${{ env.SERVER_USER }}@${{ env.SERVER_IP }}:/var/www/glam-frontend/
- name: Verify deployment
run: |
echo "Verifying deployment..."
# Check that Caddy is serving the frontend
HTTP_STATUS=$(curl -s -o /dev/null -w '%{http_code}' https://bronhouder.nl/)
if [ "$HTTP_STATUS" = "200" ]; then
echo "Frontend deployment verified: OK (HTTP $HTTP_STATUS)"
else
echo "Warning: Frontend returned HTTP $HTTP_STATUS"
fi
# Check manifest is accessible
MANIFEST_STATUS=$(curl -s -o /dev/null -w '%{http_code}' https://bronhouder.nl/schemas/20251121/linkml/manifest.json)
if [ "$MANIFEST_STATUS" = "200" ]; then
echo "Schema manifest accessible: OK"
# Show file count from manifest
curl -s https://bronhouder.nl/schemas/20251121/linkml/manifest.json | jq '.totalFiles' | xargs -I {} echo "Total schema files: {}"
else
echo "Warning: Schema manifest returned HTTP $MANIFEST_STATUS"
fi
- name: Deployment summary
run: |
echo "============================================"
echo " Frontend Deployment Complete!"
echo "============================================"
echo ""
echo "Server: ${{ env.SERVER_IP }}"
echo "Frontend URL: https://bronhouder.nl/"
echo "LinkML Viewer: https://bronhouder.nl/linkml"
echo "Schema Manifest: https://bronhouder.nl/schemas/20251121/linkml/manifest.json"
echo ""