GitHub Actions Artifact Budget Audit
Use this skill to detect oversized or stale GitHub Actions artifacts across repositories.
What this skill does
- - Reads one or more GitHub artifact JSON exports (
gh api output) - Calculates artifact size in MB and totals by repository + artifact name
- Flags warn/critical artifacts by configurable size thresholds
- Highlights soon-to-expire artifact volume to prioritize cleanup
- Supports text and JSON output for terminal or dashboards
Inputs
Optional:
- -
ARTIFACT_GLOB (default: artifacts/github-actions-artifacts/*.json) - INLINECODE3 (default:
20) - INLINECODE5 (
text or json, default: text) - INLINECODE9 (default:
250) - INLINECODE11 (default:
750) - INLINECODE13 (default:
7) - INLINECODE15 (
0 or 1, default: 0) - INLINECODE19 (regex, optional)
- INLINECODE20 (regex, optional)
- INLINECODE21 (regex, optional)
- INLINECODE22 (regex, optional)
Collect artifact JSON
Single repository:
CODEBLOCK0
Combined multi-repo payloads are also supported as long as each file includes an artifacts array.
Run
Text report:
CODEBLOCK1
JSON output for automation:
CODEBLOCK2
Filter to one repo and artifact family:
CODEBLOCK3
Run with bundled fixtures:
CODEBLOCK4
Output contract
- - Exit
0 in reporting mode (default) - Exit
1 if FAIL_ON_CRITICAL=1 and at least one artifact is at/above INLINECODE27 - In
text mode: prints summary and top oversized artifact groups - In
json mode: prints summary, grouped artifact stats, and critical artifact instances
GitHub Actions 制品预算审计
使用此技能检测跨仓库的超大或过期GitHub Actions制品。
技能功能
- - 读取一个或多个GitHub制品JSON导出文件(gh api输出)
- 计算制品大小(MB)并按仓库+制品名称汇总
- 通过可配置的大小阈值标记警告/严重制品
- 突出显示即将过期的制品体积,以便优先清理
- 支持终端或仪表盘的文本和JSON输出
输入参数
可选参数:
- - ARTIFACTGLOB(默认值:artifacts/github-actions-artifacts/*.json)
- TOPN(默认值:20)
- OUTPUTFORMAT(text或json,默认值:text)
- WARNMB(默认值:250)
- CRITICALMB(默认值:750)
- SOONEXPIRESDAYS(默认值:7)
- FAILONCRITICAL(0或1,默认值:0)
- REPOMATCH(正则表达式,可选)
- REPOEXCLUDE(正则表达式,可选)
- ARTIFACTMATCH(正则表达式,可选)
- ARTIFACT_EXCLUDE(正则表达式,可选)
收集制品JSON
单个仓库:
bash
gh api repos/<所有者>/<仓库>/actions/artifacts --paginate \
> artifacts/github-actions-artifacts/<所有者>-<仓库>.json
只要每个文件包含artifacts数组,也支持合并的多仓库负载。
运行
文本报告:
bash
ARTIFACT_GLOB=artifacts/github-actions-artifacts/*.json \
WARN_MB=300 \
CRITICAL_MB=900 \
bash skills/github-actions-artifact-budget-audit/scripts/artifact-budget-audit.sh
用于自动化的JSON输出:
bash
ARTIFACT_GLOB=artifacts/github-actions-artifacts/*.json \
OUTPUT_FORMAT=json \
FAILONCRITICAL=1 \
bash skills/github-actions-artifact-budget-audit/scripts/artifact-budget-audit.sh
过滤到单个仓库和制品系列:
bash
ARTIFACT_GLOB=artifacts/github-actions-artifacts/*.json \
REPO_MATCH=^flowcreatebot/ \
ARTIFACT_MATCH=(test-results|coverage) \
bash skills/github-actions-artifact-budget-audit/scripts/artifact-budget-audit.sh
使用捆绑的测试数据运行:
bash
ARTIFACT_GLOB=skills/github-actions-artifact-budget-audit/fixtures/*.json \
bash skills/github-actions-artifact-budget-audit/scripts/artifact-budget-audit.sh
输出约定
- - 报告模式下退出码为0(默认)
- 如果FAILONCRITICAL=1且至少有一个制品达到或超过CRITICAL_MB,退出码为1
- 在text模式下:打印摘要和最大的超标制品组
- 在json模式下:打印摘要、分组制品统计和严重制品实例