Deployment Troubleshooting Guide
This guide covers common issues with the Screeps deployment process and how to resolve them.
Overview
The deployment workflow (.github/workflows/deploy.yml) automatically deploys the compiled bot code to Screeps when:
- A version tag matching
v*is pushed - The Post Merge Release workflow completes successfully
The deployment uses scripts/deploy.ts which:
- Builds the project (
bun run build→dist/main.js) - Reads the compiled bundle
- Uploads it to the Screeps API using the
screeps-apipackage
Common Issues and Solutions
Issue: Deployment completes but code doesn’t appear in Screeps
Symptoms:
- GitHub Actions workflow shows success
- No errors in logs
- Code not visible in Screeps account
Root Cause:
This was caused by incorrect API call format. The screeps-api package expects modules as an object { moduleName: code }, but the script was passing an array format [{ name: "moduleName", body: code }].
Resolution:
Fixed in commit 663008e. The deployment script now correctly formats the API call:
1 | // ✓ Correct format |
Verification:
Run regression test: bun run test:regression -- tests/regression/deploy-api-format.test.ts
Issue: “SCREEPS_TOKEN secret is required for deployment”
Symptoms:
- Deployment fails immediately
- Error message: “SCREEPS_TOKEN secret is required for deployment”
Root Cause:
Missing or improperly configured SCREEPS_TOKEN secret in GitHub repository settings.
Resolution:
- Go to repository Settings → Secrets and variables → Actions
- Create a new repository secret named
SCREEPS_TOKEN - Value should be your Screeps API token (get from Screeps account settings)
- Re-run the deployment workflow
Issue: “Failed to read build output at dist/main.js”
Symptoms:
- Error message: “✗ Failed to read build output at dist/main.js”
- Deployment fails before upload attempt
Root Cause:
Build step failed or dist/main.js was not generated.
Resolution:
- Check build logs for errors:
bun run build - Ensure
src/main.tsexists and has no syntax errors - Verify
buildProject.tsconfiguration is correct - Check disk space and file permissions
Issue: Connection refused or timeout errors
Symptoms:
- Error message: “connect ECONNREFUSED” or timeout
- Status: 5xx errors from Screeps API
Root Cause:
Network issues or Screeps API downtime. The deployment script includes retry logic (3 attempts with exponential backoff).
Resolution:
- Check Screeps server status
- Verify
SCREEPS_HOSTconfiguration (default: screeps.com) - Check
SCREEPS_PORTandSCREEPS_PROTOCOLsettings - Wait and let the retry logic handle transient failures
- For persistent issues, run manually:
bun run deploy
Issue: Authentication errors (401/403)
Symptoms:
- Error message: “✗ Failed to upload code to Screeps API”
- Status: 401 (Unauthorized) or 403 (Forbidden)
Root Cause:
Invalid or expired API token, or insufficient permissions.
Resolution:
- Generate a new API token in Screeps account settings
- Update
SCREEPS_TOKENsecret in repository settings - Ensure token has code upload permissions
- Verify you’re targeting the correct server (PTR vs. main)
Issue: Empty string environment variables
Symptoms:
- Connection to
::1:80or empty hostname - Error: “connect ECONNREFUSED ::1:80”
Root Cause:
GitHub Actions passing empty strings instead of undefined for unset variables.
Resolution:
Already fixed. The deployment script uses || operator for defaults:
1 | const hostname = process.env.SCREEPS_HOST || "screeps.com"; |
Verification:
Run regression test: bun run test:regression -- tests/regression/deploy-env-vars.test.ts
Testing Deployment Locally
Dry Run Mode
Test deployment without actually uploading code:
1 | SCREEPS_DEPLOY_DRY_RUN=true bun run deploy |
This will:
- ✓ Build the project
- ✓ Read and validate
dist/main.js - ✓ Show deployment parameters
- ✗ Skip actual API upload
Full Local Deployment
Deploy to your Screeps account from your local machine:
1 | export SCREEPS_TOKEN="your-api-token-here" |
Testing with Act CLI
Dry-run the deployment workflow locally:
1 | # Set up test secrets |
Monitoring Deployment
Success Indicators
When deployment succeeds, you’ll see:
1 | ✓ Build output loaded (XXXXX bytes) |
Logs and Debugging
- GitHub Actions Logs: Go to Actions tab → Deploy workflow → Select run
- Enhanced Logging: The deployment script now includes:
- Progress indicators (✓, ✗, ⚠)
- Detailed error messages
- Retry attempt notifications
- API response data on failures
Configuration Reference
Environment Variables
| Variable | Default | Description |
|---|---|---|
SCREEPS_TOKEN |
(required) | API authentication token |
SCREEPS_BRANCH |
main |
Target deployment branch |
SCREEPS_HOST |
screeps.com |
Server hostname |
SCREEPS_PORT |
443 |
Server port |
SCREEPS_PROTOCOL |
https |
Connection protocol |
SCREEPS_PATH |
/ |
API base path |
SCREEPS_DEPLOY_DRY_RUN |
(unset) | Skip actual upload (test mode) |
Deployment Targets
Official Servers:
- Main server:
screeps.com(default) - PTR server: Set
SCREEPS_HOST=screeps.comwith PTR API token
Private Servers:
1 | export SCREEPS_HOST="your-server.com" |
Related Files
.github/workflows/deploy.yml- Deployment automationscripts/deploy.ts- Core deployment logicscripts/buildProject.ts- Build compilationtests/regression/deploy-api-format.test.ts- API format regression testtests/regression/deploy-env-vars.test.ts- Environment variable handling test
Further Help
If you encounter issues not covered in this guide:
- Check GitHub Actions logs for detailed error messages
- Run
bun run deploylocally with debugging enabled - Verify
screeps-apipackage version and compatibility - Review Screeps API documentation for server-specific requirements
- File an issue with reproduction steps and error logs