Updated for automatic pushing back - pulling already works via webhook

This commit is contained in:
2026-01-13 20:03:36 +01:00
parent e5ba624aa9
commit 424c20923b
5 changed files with 404 additions and 125 deletions

View File

@@ -133,6 +133,8 @@ Environment variables (set in docker-compose.yml or locally):
**Core Settings:**
- `ESPHOME_CONFIG_DIR` - Path to device configurations (default: `/config`)
- `DEBOUNCE_SECONDS` - Delay before triggering after file change (default: `5`)
- `USE_POLLING` - Use polling instead of inotify for file watching (default: `true`, required for Docker bind mounts)
- `POLLING_INTERVAL` - Seconds between filesystem polls when using polling mode (default: `1.0`)
**Gitea Configuration:**
- `GITEA_URL` - URL of Gitea instance (e.g., `https://gitea.example.com`)
@@ -237,7 +239,34 @@ The file watcher monitors all `.yaml` and `.yml` files directly in the config di
- **Ignored**: Subdirectories, non-YAML files, and hidden files (like `.git`)
- **Debouncing**: Changes are debounced for `DEBOUNCE_SECONDS` (default 5) to prevent duplicate triggers
- **Auto-push**: If `AUTO_PUSH=true`, any watched file change triggers a git commit and push
- **Commit message format**: `Auto-sync: {device_name}.yaml changed`
- **Polling Mode**: Uses filesystem polling (default) instead of inotify to ensure compatibility with Docker bind mounts on WSL2, macOS, Unraid, and other environments where inotify events don't propagate correctly through volume mounts
#### Events Detected
1. **File Modified** (`device.yaml` edited)
- Logs: "Detected change in /config/device.yaml"
- Commit message: `Auto-sync: device.yaml changed`
2. **File Created** (new `device.yaml` added)
- Logs: "Detected change in /config/device.yaml"
- Commit message: `Auto-sync: device.yaml changed`
3. **File Deleted** (`device.yaml` removed)
- Logs: "Detected deletion of /config/device.yaml"
- Commit message: `Auto-sync: device.yaml deleted`
4. **File Renamed** (`old-device.yaml` → `new-device.yaml`)
- Logs: "Rename detected: old-device.yaml -> new-device.yaml"
- Commit message: `Auto-sync: Renamed old-device.yaml to new-device.yaml`
5. **File Archived** (`device.yaml` → `archive/device.yaml`)
- Logs: "Device moved to archive/subdirectory: device"
- Commit message: `Auto-sync: device.yaml archived`
- The file deletion from `/config/` root is committed (archive folder typically in `.gitignore`)
6. **File Restored** (`archive/device.yaml` → `device.yaml`)
- Logs: "Device moved from subdirectory to config root: device"
- Commit message: `Auto-sync: device.yaml restored from archive`
Example watched files in `/config`:
- `bedroom-light.yaml` ✓
@@ -245,7 +274,7 @@ Example watched files in `/config`:
- `garage-door.yml` ✓
- `README.md` ✗ (not YAML)
- `.gitignore` ✗ (hidden file)
- `backup/old-config.yaml` ✗ (in subdirectory)
- `archive/old-config.yaml` ✗ (in subdirectory, not watched but move events detected)
### Git Authentication