GitHub Actions Troubleshooting Skill
Use the gh CLI and Git to diagnose and fix GitHub Actions workflow failures, particularly for Go projects. This skill helps identify whether failures are due to code issues or environment/configuration problems.
Workflow Analysis
Check the status of recent workflow runs:
CODEBLOCK0
View details of a specific failing workflow:
CODEBLOCK1
Get logs for failed jobs only:
CODEBLOCK2
Distinguishing Issue Types
- 1. Code Issues: Failures in compilation, tests, or linting that occur consistently across environments
- Environment Issues: Problems with dependency resolution, tool installation, or type-checking in CI that work locally
Common Go CI Fixes
Linter Configuration Issues
- - Look for "undefined" reference errors that indicate import resolution problems
- Try minimal linter configs that disable type-checking linters
- Use
golangci-lint run --disable-all --enable=gofmt for basic syntax checking
Dependency Resolution
- - Verify go.mod and go.sum are consistent
- Run
go mod tidy to resolve dependency conflicts - Check that required dependencies are properly declared
Diagnostic Commands
Check specific workflow job logs:
CODEBLOCK3
Download workflow artifacts for inspection:
CODEBLOCK4
Troubleshooting Workflow
- 1. Identify which jobs are failing and which are passing
- Examine error messages for clues about the nature of the issue
- Determine if the issue is reproducible locally
- Apply targeted fixes based on issue type
- Monitor subsequent workflow runs to verify resolution
GitHub Actions 故障排查技能
使用 gh 命令行工具和 Git 来诊断和修复 GitHub Actions 工作流故障,特别针对 Go 项目。本技能帮助识别故障是由代码问题还是环境/配置问题导致。
工作流分析
查看最近工作流运行的状态:
bash
gh run list --repo owner/repo --limit 10
查看特定失败工作流的详细信息:
bash
gh run view --repo owner/repo
仅获取失败任务的日志:
bash
gh run view --repo owner/repo --log-failed
区分问题类型
- 1. 代码问题:在不同环境中持续出现的编译、测试或代码检查失败
- 环境问题:在本地正常运行,但在 CI 中出现的依赖解析、工具安装或类型检查问题
常见 Go CI 修复方法
Linter 配置问题
- - 查找表示导入解析问题的未定义引用错误
- 尝试禁用类型检查 linter 的最小化配置
- 使用 golangci-lint run --disable-all --enable=gofmt 进行基本语法检查
依赖解析
- - 验证 go.mod 和 go.sum 的一致性
- 运行 go mod tidy 解决依赖冲突
- 检查所需依赖是否已正确声明
诊断命令
查看特定工作流任务日志:
bash
gh run view --job --repo owner/repo
下载工作流产物进行检查:
bash
gh run download --repo owner/repo
故障排查流程
- 1. 识别哪些任务失败、哪些任务通过
- 检查错误信息以获取问题性质的线索
- 确定问题是否可在本地复现
- 根据问题类型应用针对性修复
- 监控后续工作流运行以验证修复效果