mcpField
W
workflow

workflow

github.com/johnlindquist云与 DevOps2637 次安装45 周前更新
代码仓库

关于 workflow

通过 GitHub CLI 管理 GitHub Actions CI/CD 运行,供开发者查看、排查、重跑和监控工作流,并处理构建产物与手动触发。

主要功能

  1. 01按分支、工作流或状态列出运行
  2. 02查看运行详情和失败日志
  3. 03重跑工作流或失败任务
  4. 04监控运行并检查退出状态
  5. 05下载运行产物
  6. 06启用或手动触发工作流

适用场景

  1. 01合并前检查 CI 状态
  2. 02查找失败运行的日志
  3. 03修复后重试失败任务
  4. 04监控部署运行

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/johnlindquist/claude --skill workflow

安装后在 Claude Code 中输入/workflow确认已加载。

详细介绍

GitHub Actions 工作流管理器

使用 GitHub CLI 监控和管理 CI/CD 工作流。

前置条件

安装 GitHub CLI:

brew install gh
# or
curl -sS https://webi.sh/gh | sh

进行身份验证:

gh auth login

命令行参考

快速状态检查
# Current branch CI status
gh run list --branch $(git branch --show-current) --limit 5

# All recent runs
gh run list --limit 10

# Filter by workflow
gh run list --workflow "CI" --limit 5
查看特定运行
# Get run details
gh run view <run-id>

# View with logs
gh run view <run-id> --log

# Failed jobs only
gh run view <run-id> --log-failed

# Exit codes for CI scripts
gh run view <run-id> --exit-status
使用筛选条件列出运行
# By branch
gh run list --branch main --limit 10

# By workflow name
gh run list --workflow "Build and Test" --limit 10

# By status
gh run list --status failure --limit 10
gh run list --status success --limit 10
gh run list --status in_progress --limit 10

# Combined filters
gh run list --branch main --workflow "CI" --status failure --limit 5
重新运行工作流
# Rerun entire workflow
gh run rerun <run-id>

# Rerun only failed jobs
gh run rerun <run-id> --failed

# Rerun specific job
gh run rerun <run-id> --job <job-id>
监视正在运行的工作流
# Watch a run in progress
gh run watch <run-id>

# Watch and exit with run's exit code
gh run watch <run-id> --exit-status
下载产物
# List artifacts from a run
gh run view <run-id> --json artifacts

# Download all artifacts
gh run download <run-id>

# Download specific artifact
gh run download <run-id> --name "artifact-name"

# Download to specific directory
gh run download <run-id> --dir ./artifacts
取消运行
gh run cancel <run-id>
查看工作流文件
# List workflow files
gh workflow list

# View specific workflow
gh workflow view "CI"

# Enable/disable workflow
gh workflow enable "CI"
gh workflow disable "CI"
手动运行工作流
# Trigger workflow_dispatch
gh workflow run "CI"

# With inputs
gh workflow run "Deploy" -f environment=staging -f version=1.2.3

# On specific branch
gh workflow run "CI" --ref feature-branch

输出格式

# JSON output for parsing
gh run list --json status,conclusion,name,headBranch,url

# Specific fields
gh run view <run-id> --json jobs,status,conclusion

工作流模式

快速 CI 检查
# Is my branch passing?
gh run list --branch $(git branch --show-current) --limit 1 --json status,conclusion
调试失败的 CI
# 1. Find the failing run
gh run list --branch main --status failure --limit 1

# 2. View failed logs
gh run view <run-id> --log-failed

# 3. After fixing, rerun
gh run rerun <run-id> --failed
监控部署
# Watch deployment in progress
gh run watch <run-id>

# Get notified when done (macOS)
gh run watch <run-id> && osascript -e 'display notification "Deployment complete"'
重试不稳定的测试
# Rerun just the failed jobs
gh run rerun <run-id> --failed
合并前检查
# Ensure all checks pass before merging
gh run list --branch $(git branch --show-current) --json conclusion --jq '.[0].conclusion'

常见状态

状态含义
queued等待开始
in_progress当前正在运行
completed已完成
结论含义
success所有作业均通过
failure一个或多个作业失败
cancelled运行已取消
skipped运行已跳过
timed_out运行超出时间限制

最佳实践

  1. 合并前检查状态 - 确保 CI 通过
  2. 使用 --log-failed - 仅查看相关失败日志
  3. 优先重新运行 --failed - 比完整重新运行更快
  4. 监视长时间运行 - 不要手动轮询
  5. 下载产物 - 用于测试报告、覆盖率等
  6. 使用 JSON 输出 - 用于脚本编写和解析

评论

支持 Markdown