5 Commits

Author SHA1 Message Date
5ad72fe986 Fix remote sync bugs and improve error handling
Fixes two critical issues:
1. Remote clone/sync was never triggered because wmill sync ran before
   checking if workspace was empty. Reordered flow to check/clone/sync
   git repo BEFORE running wmill sync.

2. Push failures were reported as success because GitPython's push()
   doesn't raise exceptions for rejections. Added explicit checking of
   push result flags (ERROR and REJECTED).

Additional improvements:
- When workspace has files but no .git, delete contents and clone from
  remote to ensure proper sync state
- All three cases now properly sync with remote before Windmill overwrites

New flow:
1. Check workspace state and init/clone/sync git repo
2. Run wmill sync (Windmill overwrites files)
3. Commit and push (with proper error detection)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-09 22:20:52 -05:00
f276beae3b Add remote repository sync support
- Clone remote repository on first sync if workspace is empty
- Sync local repo with remote (fetch + hard reset) on subsequent syncs
- Ensures Windmill workspace changes are built on latest remote commits
- Prevents push failures due to divergent history

New functions:
- is_workspace_empty(): Check if workspace needs cloning
- clone_remote_repository(): Clone and checkout/create branch
- sync_local_with_remote(): Fetch and hard reset to remote

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-09 22:09:01 -05:00
ecc598788a Fix wmill sync authentication by using CLI flags
Replace environment variable authentication (WM_TOKEN, WM_WORKSPACE,
WM_BASE_URL) with explicit command-line flags (--token, --workspace,
--base-url) as required by wmill CLI.

According to wmill documentation, when using --base-url, the --token
and --workspace flags are required and no local workspace configuration
will be used. This is the correct approach for a stateless containerized
service where credentials are passed per-request.

This fixes the exit code 255 error that occurred when wmill tried to
run sync without proper workspace configuration.
2025-11-09 21:32:11 -05:00
0509c44497 Add MIT License and Docker build validation script
- Add MIT License with William Ballou as copyright holder
- Create scripts/validate_docker_build.sh for testing Docker builds independently
- Update documentation to reflect API-based secret configuration model
- Refactor sync.py to accept config via function parameters instead of env vars
- Update server.py to parse JSON payloads and validate required fields
- Improve security by removing secrets from environment variables
2025-11-09 20:29:52 -05:00
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