glam/.forgejo/workflows/deploy-frontend.yml
kempersc 29ef609465
Some checks failed
Deploy Frontend / build-and-deploy (push) Failing after 1m23s
fix(ci): let pnpm version be read from package.json packageManager field
The pnpm/action-setup detects version from package.json's packageManager
field automatically. Specifying version in workflow causes conflict.
2026-01-11 17:00:02 +01:00

127 lines
4.1 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 (sparse)
uses: actions/checkout@v4
with:
sparse-checkout: |
frontend
schemas
package.json
pnpm-lock.yaml
pnpm-workspace.yaml
sparse-checkout-cone-mode: false
- name: Install pnpm
uses: https://github.com/pnpm/action-setup@v4
# Version is read from package.json packageManager field
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
# Note: pnpm caching disabled due to path resolution issues with Forgejo runner
- name: Install dependencies
working-directory: frontend
run: pnpm install --frozen-lockfile
- name: Sync LinkML schemas to frontend
working-directory: frontend
run: pnpm run sync-schemas
- name: Generate schema manifest
working-directory: frontend
run: pnpm run generate-manifest
- name: Build frontend
working-directory: frontend
run: pnpm 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 ""