GitHub Actions Failure Phase Audit
Use this skill to identify which CI/CD phase is burning the most minutes when jobs fail.
What this skill does
- - Reads one or more GitHub Actions run JSON exports (
gh run view --json ...) - Detects the first non-success step per failed/cancelled/timed-out job
- Maps failures to phases:
setup, build, test, lint, deploy, security, INLINECODE7 - Aggregates failures by repo + workflow + phase + failed step
- Ranks hotspots by impacted minutes and failure count
Inputs
Optional:
- -
RUN_GLOB (default: artifacts/github-actions/*.json) - INLINECODE10 (default:
20) - INLINECODE12 (
text or json, default: text) - INLINECODE16 (default:
20) - INLINECODE18 (default:
45) - INLINECODE20 (
0 or 1, default: 0) - INLINECODE24 ,
WORKFLOW_EXCLUDE (regex, optional) - INLINECODE26 ,
REPO_EXCLUDE (regex, optional) - INLINECODE28 ,
BRANCH_EXCLUDE (regex, optional) - INLINECODE30 ,
PHASE_EXCLUDE (regex, optional)
Collect run JSON
CODEBLOCK0
Run
Text report:
CODEBLOCK1
JSON output + fail gate:
CODEBLOCK2
Phase filtered report:
CODEBLOCK3
Run with bundled fixtures:
CODEBLOCK4
Output contract
- - Exit
0 in reporting mode - Exit
1 when FAIL_ON_CRITICAL=1 and critical hotspots exist - Text output includes totals and ranked phase hotspots
- JSON output includes
summary, hotspots, and INLINECODE37
GitHub Actions 失败阶段审计
使用此技能识别当任务失败时,哪个CI/CD阶段消耗的分钟数最多。
该技能的功能
- - 读取一个或多个GitHub Actions运行JSON导出文件(gh run view --json ...)
- 检测每个失败/取消/超时任务中首个非成功步骤
- 将失败映射到以下阶段:setup、build、test、lint、deploy、security、other
- 按仓库+工作流+阶段+失败步骤聚合失败信息
- 按影响分钟数和失败次数对热点进行排名
输入参数
可选参数:
- - RUNGLOB(默认值:artifacts/github-actions/*.json)
- TOPN(默认值:20)
- OUTPUTFORMAT(text或json,默认值:text)
- WARNMINUTES(默认值:20)
- CRITICALMINUTES(默认值:45)
- FAILONCRITICAL(0或1,默认值:0)
- WORKFLOWMATCH、WORKFLOWEXCLUDE(正则表达式,可选)
- REPOMATCH、REPOEXCLUDE(正则表达式,可选)
- BRANCHMATCH、BRANCHEXCLUDE(正则表达式,可选)
- PHASEMATCH、PHASE_EXCLUDE(正则表达式,可选)
收集运行JSON
bash
gh run view --json databaseId,workflowName,headBranch,headSha,url,repository,jobs \
> artifacts/github-actions/run-.json
运行
文本报告:
bash
RUN_GLOB=artifacts/github-actions/*.json \
WARN_MINUTES=15 \
CRITICAL_MINUTES=35 \
bash skills/github-actions-failure-phase-audit/scripts/failure-phase-audit.sh
JSON输出+失败门控:
bash
RUN_GLOB=artifacts/github-actions/*.json \
OUTPUT_FORMAT=json \
FAILONCRITICAL=1 \
bash skills/github-actions-failure-phase-audit/scripts/failure-phase-audit.sh
按阶段过滤的报告:
bash
RUN_GLOB=artifacts/github-actions/*.json \
PHASE_MATCH=^(test|deploy)$ \
bash skills/github-actions-failure-phase-audit/scripts/failure-phase-audit.sh
使用内置测试数据运行:
bash
RUN_GLOB=skills/github-actions-failure-phase-audit/fixtures/*.json \
bash skills/github-actions-failure-phase-audit/scripts/failure-phase-audit.sh
输出约定
- - 报告模式下退出码为0
- 当FAILONCRITICAL=1且存在关键热点时,退出码为1
- 文本输出包含总计和按阶段排名的热点
- JSON输出包含summary、hotspots和critical_hotspots