GitHub Actions PR Gate Health Audit
Use this skill to detect unreliable pull-request merge gates before they block developers or hide degraded CI health.
What this skill does
- - Reads GitHub Actions run JSON exports
- Filters to PR/merge-gate events by default (
pull_request, pull_request_target, merge_group) - Groups by repository + workflow + event
- Scores risk using:
- failure rate
- consecutive current failures
- average queue wait before run start
- days since last successful run
- - Flags warning/critical groups via configurable thresholds
- Emits text or JSON output for CI gates and operational dashboards
Inputs
Optional:
- -
RUN_GLOB (default: artifacts/github-actions/*.json) - INLINECODE5 (default:
20) - INLINECODE7 (
text or json, default: text) - INLINECODE11 (default:
2) - INLINECODE13 (default:
^(pull_request|pull_request_target|merge_group)$) - INLINECODE15 (regex, optional)
- INLINECODE16 (regex, optional)
- INLINECODE17 (regex, optional)
- INLINECODE18 (regex, optional)
- INLINECODE19 (default:
15) - INLINECODE21 (default:
30) - INLINECODE23 (default:
120) - INLINECODE25 (default:
300) - INLINECODE27 (default:
3) - INLINECODE29 (default:
25) - INLINECODE31 (default:
45) - INLINECODE33 (
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 PR gate risk groups
- JSON mode prints summary + scored groups + critical group details
GitHub Actions PR门控健康审计
使用此技能在拉取请求合并门控阻塞开发者或隐藏降级的CI健康状况之前,检测不可靠的门控。
该技能的功能
- - 读取GitHub Actions运行JSON导出文件
- 默认过滤PR/合并门控事件(pullrequest、pullrequesttarget、mergegroup)
- 按仓库+工作流+事件进行分组
- 使用以下指标评估风险:
- 失败率
- 连续当前失败次数
- 运行开始前的平均队列等待时间
- 自上次成功运行以来的天数
- - 通过可配置阈值标记警告/严重分组
- 为CI门控和运维仪表板输出文本或JSON格式
输入参数
可选:
- - RUNGLOB(默认值:artifacts/github-actions/*.json)
- TOPN(默认值:20)
- OUTPUTFORMAT(text或json,默认值:text)
- MINRUNS(默认值:2)
- EVENTMATCH(默认值:^(pullrequest|pullrequesttarget|mergegroup)$)
- WORKFLOWMATCH(正则表达式,可选)
- WORKFLOWEXCLUDE(正则表达式,可选)
- REPOMATCH(正则表达式,可选)
- REPOEXCLUDE(正则表达式,可选)
- FAILWARNPERCENT(默认值:15)
- FAILCRITICALPERCENT(默认值:30)
- QUEUEWARNSECONDS(默认值:120)
- QUEUECRITICALSECONDS(默认值:300)
- SUCCESSSTALEDAYS(默认值:3)
- WARNSCORE(默认值:25)
- CRITICALSCORE(默认值:45)
- FAILON_CRITICAL(0或1,默认值:0)
收集运行JSON
bash
gh run view --json databaseId,workflowName,event,conclusion,headBranch,headSha,createdAt,runStartedAt,updatedAt,url,repository \
> artifacts/github-actions/run-.json
运行
文本报告:
bash
RUN_GLOB=artifacts/github-actions/*.json \
EVENTMATCH=^(pullrequest|merge_group)$ \
MIN_RUNS=3 \
bash skills/github-actions-pr-gate-health-audit/scripts/pr-gate-health-audit.sh
带失败门控的JSON输出:
bash
RUN_GLOB=artifacts/github-actions/*.json \
OUTPUT_FORMAT=json \
FAILONCRITICAL=1 \
bash skills/github-actions-pr-gate-health-audit/scripts/pr-gate-health-audit.sh
使用捆绑测试数据运行:
bash
RUN_GLOB=skills/github-actions-pr-gate-health-audit/fixtures/*.json \
bash skills/github-actions-pr-gate-health-audit/scripts/pr-gate-health-audit.sh
输出约定
- - 报告模式下退出码为0(默认)
- 当FAILONCRITICAL=1且存在一个或多个严重分组时,退出码为1
- 文本模式打印摘要+排名后的PR门控风险分组
- JSON模式打印摘要+评分分组+严重分组详情