SuperAPI AI 工具集

ci-cd-pipeline-builder

部署与运维

查看项目

更新于 10-14 19:30

技能介绍

CI/CD Pipeline Builder

层级:POWERFUL

类别:Engineering

领域:DevOps / Automation

概述

使用此技能基于检测到的项目技术栈信号生成务实的 CI/CD 流水线,而非猜测。它专注于快速生成基线、可重复的检查以及环境感知的部署阶段。

核心能力

  • 从仓库文件检测语言/运行时/工具链
  • 推荐 CI 阶段(lint、test、build、deploy)
  • 生成 GitHub Actions 或 GitLab CI 起始流水线
  • 基于检测到的技术栈包含缓存和矩阵策略
  • 输出可机读的检测结果以供自动化使用
  • 保持流水线逻辑与项目锁文件和构建命令一致

何时使用

  • 为新仓库引导 CI
  • 替换脆弱的复制版流水线文件
  • 在 GitHub Actions 与 GitLab CI 之间迁移
  • 审计流水线步骤是否与实际技术栈匹配
  • 在自定义加固前创建可复现基线

关键工作流

  1. 检测技术栈
python3 scripts/stack_detector.py --repo . --format text
python3 scripts/stack_detector.py --repo . --format json > detected-stack.json

支持通过 stdin 或 --input 文件输入,用于离线分析负载。

  1. 基于检测结果生成流水线
python3 scripts/pipeline_generator.py \
  --input detected-stack.json \
  --platform github \
  --output .github/workflows/ci.yml \
  --format text

或直接从仓库端到端生成:

python3 scripts/pipeline_generator.py --repo . --platform gitlab --output .gitlab-ci.yml
  1. 合并前验证
  • 确认命令在项目中存在(test、lint、build)。
  • 尽可能在本地运行生成的流水线。
  • 确保所需的 secrets/env vars 已记录。
  • 通过受保护分支/环境限制部署任务。
  1. 安全添加部署阶段
  • 从仅 CI(lint/test/build)开始。
  • 添加带有明确环境上下文的 staging 部署。
  • 添加带有手动门禁/审批的 production 部署。
  • 保持发布/回滚命令明确且可审计。

脚本接口

python3 scripts/stack_detector.py --help
  • 从仓库文件检测技术栈信号
  • 从 stdin/--input 读取可选 JSON 输入
python3 scripts/pipeline_generator.py --help
  • 从检测负载生成 GitHub/GitLab YAML
  • 输出到 stdout 或 --output

参考

  • references/pipeline-design-notes.md — 常见陷阱、最佳实践、检测启发式、生成策略、平台决策说明、合并前验证清单及扩展指导
  • references/github-actions-templates.md
  • references/gitlab-ci-templates.md
  • references/deployment-gates.md
  • README.md