Workflow Troubleshooting Guide
This guide covers common issues and troubleshooting steps for GitHub Actions workflows in the .screeps-gpt repository.
Post Merge Release Workflow Issues
Git Push Conflict with –force-with-lease
Problem: The post-merge release workflow fails at the “Commit changes to release branch” step with:
1 | ! [rejected] HEAD -> release/v0.X.Y (stale info) |
Root Cause: This occurs when there’s a race condition between multiple workflow runs or when the remote repository has been updated between the fetch and push operations, causing the --force-with-lease option to fail due to stale lease information.
Solution (Fixed in #104):
- Added “Update remote refs” step before committing to ensure fresh ref information
- Set
skip_fetch: falsein the git-auto-commit-action to fetch latest refs - Used
git fetch origin --pruneandgit remote prune originto clean up stale refs
Prevention: The regression test tests/regression/post-merge-workflow-git-race-condition.test.ts validates the fix remains in place.
Related Issues:
- Workflow run: #18703919715
- Fix PR: #104
Version Bump Conflicts
Problem: Multiple concurrent merges to main can cause version bump conflicts.
Mitigation:
- The workflow includes a condition to skip if the commit message contains “chore: prepare release”
- Use of
--force-with-leaseprevents accidental overwrites - Fresh ref fetching ensures latest state before operations
Quality Gate Workflow Issues
Test Failures Due to Missing Dependencies
Problem: Tests fail with “command not found” errors for Node.js tools.
Solution:
- Ensure Node.js 16 setup is complete before running tests
- Run
bun installto install dependencies - Use proper environment variables for build tools
Lint Failures
Problem: ESLint or Prettier checks fail in CI.
Solution:
- Run
bun run lint:fixlocally before committing - Run
bun run format:writeto auto-format code - Check for TypeScript compilation errors
Deploy Workflow Issues
Screeps API Authentication
Problem: Deployment fails with authentication errors.
Solution:
- Verify
SCREEPS_USERNAME,SCREEPS_PASSWORD, andSCREEPS_BRANCHsecrets are set - Check that the Screeps account has proper permissions
- Ensure the API is accessible (not blocked by rate limits)
Reference: See docs/operations/deployment-troubleshooting.md for detailed deployment issues.
General Troubleshooting Steps
Check Workflow Logs
- Navigate to the failed workflow run
- Expand the failed step to see detailed error messages
- Look for specific error codes or patterns
Validate Secrets and Environment Variables
- Check that required secrets are set in repository settings
- Verify secret names match those used in workflows
- Test secrets in a minimal reproduction case if possible
Dependency Issues
- Check for dependency conflicts in package-lock.json
- Verify Node.js version compatibility (16.20.2)
- Clear npm cache if needed:
npm cache clean --force
Concurrent Workflow Runs
- Check if multiple workflows are running simultaneously
- Consider adding workflow concurrency controls if needed
- Use appropriate git strategies (force-with-lease, fresh fetches)
Monitoring and Alerting
Workflow Status Monitoring
The repository includes automated monitoring via:
copilot-ci-autofix.yml- Automatically attempts to fix CI failurescopilot-review.yml- Scheduled repository health checks
Issue Creation
Failed workflows automatically create issues for investigation when:
- Multiple consecutive failures occur
- Critical path workflows (deploy, release) fail
- Security or dependency vulnerabilities are detected
Best Practices
Writing Robust Workflows
- Always fetch fresh refs before git operations
- Use
--force-with-leaseinstead of--forcefor safety - Include proper error handling and retry logic
- Add regression tests for fixed issues
- Document troubleshooting steps for common failures
Testing Workflows
- Use
bun run test:actionsto dry-run workflows locally - Test with representative data and edge cases
- Verify secrets and environment setup in test environments
- Include both success and failure scenarios in testing
For additional help, check the automation documentation in docs/automation/overview.md or create an issue with the automation and needs/investigation labels.