Conversation
Implements polling-based auto-deployment that detects changes to the main branch and automatically deploys them to the host system. Features: - Polls origin/main every 60 seconds (configurable) for new commits - Executes full deployment: pull, install deps, build, restart service - Sends real-time notifications to main chat about deployment progress - Handles uncommitted changes by stashing them - Verifies service is running after deployment - Comprehensive error handling and notifications Configuration: - AUTO_DEPLOY_ENABLED (default: true) - AUTO_DEPLOY_POLL_INTERVAL (default: 60000ms) Changes: - src/auto-deploy.ts: Core deployment logic and polling loop - src/index.ts: Wire up auto-deploy on startup - src/config.ts: Add auto-deploy config, export PROJECT_ROOT and HOME_DIR - docs/AUTO_DEPLOYMENT.md: Comprehensive documentation This will enable PR #2 to deploy automatically once PR #3 is merged. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
| AUTO_DEPLOY_ENABLED=false | ||
|
|
||
| # Change polling interval (default: 60000ms = 1 minute) | ||
| AUTO_DEPLOY_POLL_INTERVAL=120000 # Check every 2 minutes |
There was a problem hiding this comment.
Polling faster than 1 second is never going to be reasonable, so we don't need millisecond precision here. To make the configuration more obvious and hint at its intent, lets configure by seconds instead
| - ✅ Documentation updates | ||
| - ✅ Any other changes to tracked files | ||
|
|
||
| **Note:** Container rebuild (Dockerfile changes) is not yet automated. If the Dockerfile changes, you'll need to rebuild manually: |
There was a problem hiding this comment.
Why stop here? We should automate this part, too.
Changed AUTO_DEPLOY_POLL_INTERVAL (ms) to AUTO_DEPLOY_POLL_INTERVAL_SECONDS to make configuration more obvious and hint at its intent. Sub-second polling is never reasonable for git operations. Changes: - src/config.ts: Rename to AUTO_DEPLOY_POLL_INTERVAL_SECONDS, default 60 - src/index.ts: Convert seconds to ms when calling startAutoDeployLoop - docs/AUTO_DEPLOYMENT.md: Update all examples to use seconds Examples: - Default: 60 (1 minute) - Production: 300 (5 minutes) - Development: 30 (30 seconds) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
| ### What It CAN Do | ||
|
|
||
| - ✅ Pull changes from `origin/main` | ||
| - ✅ Stash local uncommitted changes (non-destructively) |
There was a problem hiding this comment.
When manually validating these steps, I encountered files that were committed to the branch in the container, but were untracked on the host. Pulling from main after the branch was merged caused a conflict and git prevented the pull. How does this automation address that scenario?
| ## Manual Rollback | ||
|
|
||
| If auto-deployment causes issues, you can manually roll back: |
There was a problem hiding this comment.
If we can tell that the npm install/build, docker build, or service restart failed, we should automatically trigger a rollback to the previous commit and rerun everything to build and restart the service from that (theoretically) known-working state.
- Add --include-untracked flag to git stash to catch untracked files - This addresses scenario where files are committed in container but untracked on host - Update documentation to explain this behavior and differentiate from true merge conflicts
| GitHub API has rate limits for fetching: | ||
| - **Authenticated**: 5,000 requests/hour | ||
| - **Unauthenticated**: 60 requests/hour | ||
|
|
||
| With 1-minute polling, you'll make 60 requests/hour, which is fine for authenticated access. | ||
|
|
||
| **Solution**: Ensure git credentials are configured for authenticated access. |
There was a problem hiding this comment.
With this in mind, we should default to 2-minute polling. That way any problem with authentication would only burn through half the allotted request rate, worst case.
- On any critical failure (install, build, container rebuild, restart, verify), automatically: - Reset to previous commit with git reset --hard - Reinstall dependencies - Rebuild TypeScript - Restart service - Verify service is active - Send detailed notifications during rollback process - If rollback fails, notify user that manual intervention is required - Update documentation to explain automatic rollback behavior
- More conservative rate to avoid GitHub API limits - With 2-minute polling: 30 requests/hour (safe even without auth) - With 1-minute polling: 60 requests/hour (exhausts unauthenticated limit) - Update all documentation to reflect new default - Adjust examples to show 2 minutes as balanced default
Summary
Implements polling-based automatic deployment that detects when the
mainbranch is updated and automatically deploys changes to the host system.Key Features
origin/mainevery 60 seconds (configurable viaAUTO_DEPLOY_POLL_INTERVAL)Configuration
Example Notifications
Successful deployment:
Failed deployment:
Changes
AUTO_DEPLOY_*config, exportPROJECT_ROOTandHOME_DIRTesting Plan
Once PR #3 is merged:
This PR sets up the infrastructure, and PR #2 will be the first real test of the automation!
Security Considerations
Future Enhancements
v1.0.0)Documentation
See docs/AUTO_DEPLOYMENT.md for: