Files
windmill-git-sync/app/server.py
Bill c838fa568c Initial commit: Windmill Git Sync service
Add containerized service for syncing Windmill workspaces to Git repositories.

Features:
- Flask webhook server for triggering syncs from Windmill
- wmill CLI integration for pulling workspace content
- Automated Git commits and push to remote repository
- Network-isolated (only accessible within Docker network)
- Designed to integrate with existing Windmill docker-compose files

Key components:
- Docker container with Python 3.11, wmill CLI, Git, and Flask
- Sync engine with error handling and logging
- External volume support for persistent workspace data
- Comprehensive documentation (README.md and CLAUDE.md)
2025-11-08 18:40:26 -05:00

55 lines
1.5 KiB
Python

#!/usr/bin/env python3
"""
Flask server for receiving webhook triggers from Windmill to sync workspace to Git.
Internal service - not exposed outside Docker network.
"""
import logging
from flask import Flask, jsonify
from sync import sync_windmill_to_git
# Configure logging
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)
logger = logging.getLogger(__name__)
app = Flask(__name__)
@app.route('/health', methods=['GET'])
def health():
"""Health check endpoint."""
return jsonify({'status': 'healthy'}), 200
@app.route('/sync', methods=['POST'])
def trigger_sync():
"""
Trigger a sync from Windmill workspace to Git repository.
This endpoint is only accessible within the Docker network.
"""
logger.info("Sync triggered via webhook")
try:
result = sync_windmill_to_git()
if result['success']:
logger.info(f"Sync completed successfully: {result['message']}")
return jsonify(result), 200
else:
logger.error(f"Sync failed: {result['message']}")
return jsonify(result), 500
except Exception as e:
logger.exception("Unexpected error during sync")
return jsonify({
'success': False,
'message': f'Sync failed with error: {str(e)}'
}), 500
if __name__ == '__main__':
logger.info("Starting Windmill Git Sync server on port 8080")
app.run(host='0.0.0.0', port=8080, debug=False)