GitHub日志分析_analyze-github-action-logs

以下为本文档的中文说明

该技能用于获取和分析GitHub Actions工作流的最近运行日志,识别流程中的模式、错误和可改进之处。功能涵盖从日志拉取到深度分析再到改进建议报告的全流程。使用场景包括CI/CD流水线故障排查、工作流运行效率评估、识别重复性失败模式、发现浪费时间的冗余步骤,以及制定具体的优化方案。工作流程分为三个步骤:第一步获取最近完成的运行列表,使用gh run list --workflow=<workflow> -R <repo> --status=completed -L <count>命令获取运行ID、标题和状态信息;第二步逐个分析每个运行的详细信息,检查花费时间最长的作业和步骤、分析失败步骤的错误信息、统计重试次数和人工介入频率;第三步生成结构化分析报告,包括问题分类(基础设施问题、配置错误、代码问题、外部依赖失败等)、每个问题的频率和影响评估、优先级排序以及具体的改进建议。核心特点在于其数据驱动的分析方式——不是凭直觉猜测问题,而是基于实际运行数据进行系统化的模式识别。核心原则是’先量化再优化’,通过统计各步骤的平均耗时、失败率和手动干预次数,找到真正的瓶颈所在。该技能特别适合维护大型开源项目的团队,可以有效减少CI/CD流程中的资源浪费和重复劳动。


Analyze GitHub Action Logs

Fetch and analyze recent GitHub Actions runs for a given workflow. Review agent/step performance, identify wasted effort and mistakes, and produce a report with actionable improvements.

Input

You need:

  • workflow (required) — The workflow file name or ID (e.g., issue-triage.yml, deploy.yml).
  • repo (optional) — The GitHub repository in OWNER/REPO format. Defaults to withastro/astro.
  • count (optional) — Number of recent completed runs to analyze. Defaults to 5.

Step 1: List Recent Runs

Fetch the most recent completed runs for the workflow. Filter by --status=completed:

gh run list --workflow=<workflow> -R <repo> --status=completed -L <count>

Present the list to orient yourself: run IDs, titles, status (success/failure), and duration. Pick the runs to analyze — prefer a mix of successes and failures if available, and prefer runs that exercised more steps (longer runs tend to go through more stages, while shorter runs may exit early).

Step 2: Fetch Logs

For each run you want to analyze, save the full log to a temp file:

gh run view <run_id> -R <repo> --log > /tmp/actions-run-<run_id>.log

Step 3: Identify Step/Skill Boundaries

Search each log file for markers that indicate where each step or skill starts and ends. The markers depend on the workflow — look for patterns like:

  • Flue skill markers: [flue] skill("..."): starting / completed
  • GitHub Actions step markers: Step name headers in the log output
  • Custom markers: Any START/END or similar delimiters the workflow uses
grep -n "skill(\\|step\\|START\\|END\\|starting\\|completed" /tmp/actions-run-<run_id>.log | head -50

From this, determine which line ranges correspond to each step/skill. Also find any result markers:

grep -n "RESULT_START\\|RESULT_END\\|extractResult" /tmp/actions-run-<run_id>.log

Note: Some log files may contain binary/null bytes. Use grep -a if needed.

Step 4: Analyze Each Step (Use Subagents)

For each step/skill that ran, launch a subagent to analyze that section’s log. This is critical to avoid polluting your context with thousands of log lines.

For each subagent, provide:

  1. The log file path and the line range for that step
  2. If skill instruction files exist for the workflow, tell the subagent to read them first for context
  3. The run title/context so the subagent understands what was being done
  4. The analysis criteria below

Analysis Criteria

Tell each subagent to evaluate:

  1. Correctness — Was the step’s final result/verdict correct?
  2. Efficiency — How long did it take? What’s a reasonable baseline? Where was time wasted?
  3. Mistakes — Wrong tool calls, failed commands retried without changes, unnecessary rebuilds, etc.
  4. Instruction compliance — If skill instructions exist, did the agent follow them? Where did it deviate?
  5. Scope creep — Did the agent do work that belongs in a different step?
  6. Suggestions — Specific, actionable changes that would prevent the issues found.

Tell each subagent to return a structured response with: Summary, Time Analysis, Issues Found (with estimated time wasted for each), and Suggestions for Improvement.

Step 5: Consolidate Report

After all subagents return, synthesize their findings into a single report. Structure it as:

Per-Run Summary Table

For each run analyzed, include a table:

Step/SkillTimeResultTime WastedTop Issue

Cross-Cutting Patterns

Identify issues that appeared across multiple runs or multiple steps. These are the highest-value improvements. Common patterns to look for:

  • TodoWrite abuse — Agent wasting time on task list management during automated runs
  • Server management failures — Port conflicts, failed process kills, stale log files
  • Tool misuse — Using curl instead of gh, jq not found, etc.
  • Scope creep — One step doing work that belongs in another
  • U
    nnecessary rebuilds
    — Building packages multiple times without changes
  • Test timeouts — Running slow E2E/Playwright tests that time out
  • Instruction violations — Agent doing something the instructions explicitly forbid
  • Redundant work — Re-reading files, re-running searches, re-installing dependencies

Prioritized Recommendations

Rank your improvement suggestions by estimated time savings across all runs. For each recommendation:

  1. What to change — Which file(s) to edit and what to add/modify
  2. Why — What pattern it addresses, with evidence from the runs
  3. Estimated impact — How much time it would save per run

Output

Present the full consolidated report. Do NOT edit any workflow or skill files — only report findings and recommendations. The user will decide which changes to apply.
3e:[“","","","L41”,null,{“content”:“$42”,“frontMatter”:{“name”:“analyze-github-action-logs”,“description”:“Analyze recent GitHub Actions workflow runs to identify patterns, mistakes, and improvements. Use when asked to \“analyze workflow logs\”, \“review action runs\”, or \“analyze GitHub Actions\”.”,“compatibility”:“Requires gh CLI and access to the GitHub repository.”}}]

3f:[“KaTeX parse error: Expected '}', got 'EOF' at end of input: …,"children":[["”,“div”,null,{“className”:“flex items-center justify-between border-b border-border bg-muted/30 px-4 py-2.5”,“children”:[[“KaTeX parse error: Expected '}', got 'EOF' at end of input: …","children":["”,“span”,null,{“className”:“truncate text-xs font-medium text-muted-foreground”,“children”:“同仓库更多 Skills”}]}],[“KaTeX parse error: Expected 'EOF', got '}' at position 88: …ldren":"同仓库"}]]}̲],["”,“div”,null,{“className”:“p-4 sm:p-5”,“children”:[[“","h2",null,"id":"related−skills−heading","className":"text−2xlfont−semiboldtracking−normaltext−foreground","children":"同仓库更多Skills"],["","h2",null,{"id":"related-skills-heading","className":"text-2xl font-semibold tracking-normal text-foreground","children":"同仓库更多 Skills"}],["","h2",null,"id":"relatedskillsheading","className":"text2xlfontsemiboldtrackingnormaltextforeground","children":"同仓库更多Skills"],["”,“div”,null,{“className”:“mt-4 grid gap-3 sm:grid-cols-2”,“children”:[“L43","L43","L43","L44”,“L45","L45","L45","L46”,“$L47”]}]]}]]}]

48:I[206516,[“/_next/static/chunks/051aanbhrv4br.js”,“/_next/static/chunks/0mizr60h7ayzt.js”,“/_next/static/chunks/0v9lm1dmbdoo-.js”,“/_next/static/chunks/0rxr1j1j3j-.r.js”,“/_next/static/chunks/02ftybezfvqjd.js”,“/_next/static/chunks/0.v9ksvnnj8ia.js”,“/_next/static/chunks/0bn6id96nx3k.js",“/_next/static/chunks/13ybnhn37c.tc.js”,“/_next/static/chunks/0_fnrdtruz8uf.js”,“/_next/static/chunks/0r6l15utt1mwb.js”,“/_next/static/chunks/0dm9a5into854.js”,"/_next/static/chunks/07k6hqoibtcn.js”,“/next/static/chunks/0b4cao.4y…j.js”,“/_next/static/chunks/02i-n28z7kjd0.js”],“default”]

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值