finops-workflows

📁 laurigates/claude-plugins 📅 4 days ago
26
总安装量
2
周安装量
#14327
全站排名
安装命令
npx skills add https://github.com/laurigates/claude-plugins --skill finops-workflows

Agent 安装分布

amp 2
gemini-cli 2
github-copilot 2
codex 2
kimi-cli 2
opencode 2

Skill 文档

/finops:workflows

Analyze GitHub Actions workflow runs for a repository – frequency, duration, success rates, and efficiency metrics.

Context

  • Current repo: !gh repo view --json nameWithOwner --jq '.nameWithOwner' 2>/dev/null

Parameters

Parameter Description Default
repo Repository in owner/name format Current repository

Execution

1. Determine repository:

REPO="${1:-$(gh repo view --json nameWithOwner --jq '.nameWithOwner')}"
echo "Analyzing workflows for: $REPO"

2. List active workflows:

echo ""
echo "=== Active Workflows ==="
gh workflow list --repo "$REPO" --json id,name,state \
  --jq '.[] | select(.state == "active") | "  \(.name) (id: \(.id))"'

3. Workflow run summary (last 30 days):

echo ""
echo "=== Run Summary (last 30 days) ==="
gh api "/repos/$REPO/actions/runs?per_page=100" \
  --jq '.workflow_runs | group_by(.name) |
        map({
          name: .[0].name,
          total: length,
          success: ([.[] | select(.conclusion == "success")] | length),
          failure: ([.[] | select(.conclusion == "failure")] | length),
          cancelled: ([.[] | select(.conclusion == "cancelled")] | length),
          skipped: ([.[] | select(.conclusion == "skipped")] | length)
        }) |
        sort_by(-.total)[] |
        "\(.name):\n  Total: \(.total) | Success: \(.success) | Failure: \(.failure) | Cancelled: \(.cancelled) | Skipped: \(.skipped)\n  Success rate: \(if .total > 0 then ((.success / .total * 100) | floor) else 0 end)%"'

4. Duration analysis (completed runs):

echo ""
echo "=== Duration Analysis ==="
gh api "/repos/$REPO/actions/runs?per_page=50&status=completed" \
  --jq '.workflow_runs | group_by(.name) |
        map({
          name: .[0].name,
          count: length,
          durations: [.[] | (.run_started_at as $start | .updated_at as $end |
                      (($end | fromdateiso8601) - ($start | fromdateiso8601)))],
        }) |
        map({
          name: .name,
          count: .count,
          avg_seconds: (if .count > 0 then (.durations | add / length | floor) else 0 end),
          max_seconds: (if .count > 0 then (.durations | max) else 0 end),
          total_seconds: (.durations | add)
        }) |
        sort_by(-.total_seconds)[] |
        "\(.name):\n  Runs: \(.count) | Avg: \(.avg_seconds / 60 | floor)m\(.avg_seconds % 60)s | Max: \(.max_seconds / 60 | floor)m\(.max_seconds % 60)s | Total: \(.total_seconds / 60 | floor)min"'

5. Trigger breakdown:

echo ""
echo "=== Trigger Types ==="
gh api "/repos/$REPO/actions/runs?per_page=100" \
  --jq '.workflow_runs | group_by(.event) |
        map({event: .[0].event, count: length}) |
        sort_by(-.count)[] |
        "  \(.event): \(.count) runs"'

6. Recent failures:

echo ""
echo "=== Recent Failures (last 10) ==="
gh api "/repos/$REPO/actions/runs?per_page=100&status=completed" \
  --jq '[.workflow_runs[] | select(.conclusion == "failure")] | .[0:10][] |
        "  #\(.run_number) \(.name) - \(.created_at | split("T")[0]) - \(.html_url)"'

7. High-frequency workflows (>2 runs/day average):

echo ""
echo "=== High Frequency Workflows ==="
gh api "/repos/$REPO/actions/runs?per_page=100" \
  --jq '.workflow_runs | group_by(.name) |
        map(select(length > 60)) |
        map({name: .[0].name, runs: length, per_day: (length / 30 | . * 10 | floor / 10)}) |
        sort_by(-.runs)[] |
        "  \(.name): \(.runs) runs (~\(.per_day)/day) - consider path filters"'

Output Format

Analyzing workflows for: org/repo

=== Active Workflows ===
  CI (id: 12345)
  Deploy (id: 12346)
  CodeQL (id: 12347)

=== Run Summary (last 30 days) ===
CI:
  Total: 156 | Success: 140 | Failure: 10 | Cancelled: 4 | Skipped: 2
  Success rate: 89%
Deploy:
  Total: 45 | Success: 44 | Failure: 1 | Cancelled: 0 | Skipped: 0
  Success rate: 97%

=== Duration Analysis ===
CI:
  Runs: 50 | Avg: 4m32s | Max: 12m15s | Total: 226min
Deploy:
  Runs: 20 | Avg: 2m10s | Max: 3m45s | Total: 43min

=== Trigger Types ===
  push: 89 runs
  pull_request: 67 runs
  schedule: 30 runs
  workflow_dispatch: 5 runs

=== Recent Failures (last 10) ===
  #234 CI - 2025-01-28 - https://github.com/org/repo/actions/runs/...
  #231 CI - 2025-01-27 - https://github.com/org/repo/actions/runs/...

=== High Frequency Workflows ===
  CI: 156 runs (~5.2/day) - consider path filters

Post-actions

Based on findings, suggest:

  • High failure rate → Investigate recent failures, check logs with gh run view --log-failed
  • High frequency → Review trigger conditions, add path filters
  • Long durations → Review caching, parallelization, step optimization
  • Many skipped → Run /finops:waste for detailed analysis