GitHub Actions Mainline Health Audit
Use this skill to detect unstable workflows on protected branches (main/master/release) before they silently degrade delivery confidence.
What this skill does
- - Reads GitHub Actions run JSON exports
- Filters to mainline/protected branches (configurable regex)
- Groups by repository + workflow + branch + event
- Scores risk using:
- failure rate
- current consecutive failure streak
- days since last successful run
- - Flags warning/critical groups based on configurable thresholds
- Emits text or JSON output for CI checks and ops dashboards
Inputs
Optional:
- -
RUN_GLOB (default: artifacts/github-actions/*.json) - INLINECODE2 (default:
20) - INLINECODE4 (
text or json, default: text) - INLINECODE8 (default:
2) - INLINECODE10 (default:
^(main|master|release.*)$) - INLINECODE12 (regex, optional)
- INLINECODE13 (regex, optional)
- INLINECODE14 (regex, optional)
- INLINECODE15 (regex, optional)
- INLINECODE16 (regex, optional)
- INLINECODE17 (regex, optional)
- INLINECODE18 (regex, optional)
- INLINECODE19 (regex, optional)
- INLINECODE20 (regex, optional)
- INLINECODE21 (regex, optional)
- INLINECODE22 (regex, optional)
- INLINECODE23 (regex, optional)
- INLINECODE24 (regex, optional)
- INLINECODE25 (regex, optional)
- INLINECODE26 (default:
20) - INLINECODE28 (default:
40) - INLINECODE30 (default:
7) - INLINECODE32 (default:
30) - INLINECODE34 (default:
55) - INLINECODE36 (
0 or 1, default: 0)
Collect run JSON
CODEBLOCK0
Run
Text report:
CODEBLOCK1
JSON output with fail gate:
CODEBLOCK2
Run with bundled fixtures:
CODEBLOCK3
Output contract
- - Exit
0 in report mode (default) - Exit
1 when FAIL_ON_CRITICAL=1 and one or more groups are critical - Text mode prints summary + ranked mainline-risk groups
- JSON mode prints summary + scored groups + critical group details
GitHub Actions 主线健康审计
使用此技能检测受保护分支(main/master/release)上的不稳定工作流,防止它们在不知不觉中降低交付信心。
此技能的功能
- - 读取 GitHub Actions 运行 JSON 导出文件
- 过滤至主线/受保护分支(可配置正则表达式)
- 按仓库 + 工作流 + 分支 + 事件分组
- 使用以下指标进行风险评分:
- 失败率
- 当前连续失败次数
- 自上次成功运行以来的天数
- - 根据可配置阈值标记警告/严重组
- 输出文本或 JSON 格式,用于 CI 检查和运维仪表板
输入参数
可选参数:
- - RUNGLOB(默认值:artifacts/github-actions/.json)
- TOPN(默认值:20)
- OUTPUTFORMAT(text 或 json,默认值:text)
- MINRUNS(默认值:2)
- MAINLINEBRANCHMATCH(默认值:^(main|master|release.)$)
- WORKFLOWMATCH(正则表达式,可选)
- WORKFLOWEXCLUDE(正则表达式,可选)
- EVENTMATCH(正则表达式,可选)
- EVENTEXCLUDE(正则表达式,可选)
- REPOMATCH(正则表达式,可选)
- REPOEXCLUDE(正则表达式,可选)
- HEADSHAMATCH(正则表达式,可选)
- HEADSHAEXCLUDE(正则表达式,可选)
- CONCLUSIONMATCH(正则表达式,可选)
- CONCLUSIONEXCLUDE(正则表达式,可选)
- RUNIDMATCH(正则表达式,可选)
- RUNIDEXCLUDE(正则表达式,可选)
- RUNURLMATCH(正则表达式,可选)
- RUNURLEXCLUDE(正则表达式,可选)
- FAILWARNPERCENT(默认值:20)
- FAILCRITICALPERCENT(默认值:40)
- STALESUCCESSDAYS(默认值:7)
- WARNSCORE(默认值:30)
- CRITICALSCORE(默认值:55)
- FAILONCRITICAL(0 或 1,默认值:0)
收集运行 JSON
bash
gh run view --json databaseId,workflowName,event,conclusion,headBranch,headSha,createdAt,updatedAt,startedAt,url,repository \
> artifacts/github-actions/run-.json
运行
文本报告:
bash
RUN_GLOB=artifacts/github-actions/*.json \
MAINLINEBRANCHMATCH=^(main|release/.*)$ \
HEADSHAMATCH=^[a-f0-9]{7,40}$ \
CONCLUSION_EXCLUDE=^(success)$ \
RUNIDMATCH=^50(0[1-5])$ \
MIN_RUNS=3 \
bash skills/github-actions-mainline-health-audit/scripts/mainline-health-audit.sh
带失败门的 JSON 输出:
bash
RUN_GLOB=artifacts/github-actions/*.json \
OUTPUT_FORMAT=json \
FAILONCRITICAL=1 \
bash skills/github-actions-mainline-health-audit/scripts/mainline-health-audit.sh
使用捆绑测试数据运行:
bash
RUN_GLOB=skills/github-actions-mainline-health-audit/fixtures/*.json \
bash skills/github-actions-mainline-health-audit/scripts/mainline-health-audit.sh
输出约定
- - 报告模式下退出码为 0(默认)
- 当 FAILONCRITICAL=1 且存在一个或多个严重组时,退出码为 1
- 文本模式打印摘要 + 排名后的主线风险组
- JSON 模式打印摘要 + 评分组 + 严重组详情