生成适用于所选语言、框架、测试、部署和发布等的生产级 CI/CD 工作流文件,支持 GitHub Actions、GitLab CI 或 Jenkins。
Name: CI/CD Templates Generator ( cicd-gen)
Type: CLI Tool + OpenClaw Skill
Purpose: 一键生成生产级 CI/CD workflow 文件(GitHub Actions / GitLab CI / Jenkins)
Author: kay
Version: 1.0.0
text
cicd-gen <language> [framework] [options]
触发词示例:
语言框架测试框架部署选项发布Pythonflask, django, fastapipytest, unittestdocker, azure, aliyun, tencent, k8s, serverless—JavaScriptnode, expressjest, mochadocker, azure, aliyun, tencentnpm publishGogin, echogo-testdockergoreleaser
on.scheduleon.pull_requestbash
# 基本用法
cicd-gen python flask --test pytest --output ./.github/workflows/
# Python + pytest + Docker
cicd-gen python flask --test pytest --deploy docker
# Python + pytest + Docker + Azure 部署
cicd-gen python flask --test pytest --deploy docker --cloud azure
# Python + unittest + 覆盖率
cicd-gen python django --test unittest --coverage
# JavaScript + Jest
cicd-gen javascript node --test jest
# JavaScript + Jest + Docker + npm 发布
cicd-gen javascript node --test jest --deploy docker --release npm
# Go + goreleaser
cicd-gen go gin --test go-test --release goreleaser
# 多平台输出
cicd-gen python flask --test pytest --format all
# 仅打印不写文件
cicd-gen python flask --test pytest --print-only
# 自定义版本
cicd-gen python flask --test pytest --python-version 3.10 --name "My CI"
参数说明默认值languagepython / javascript / go必填frameworkflask / django / node / gin / echo 等可选--test, -t测试框架自动检测 (pytest/jest/go-test)--deploy, -d部署目标无--release, -r发布工具 (npm/goreleaser)无--coverage, -c启用覆盖率报告False--cloud云服务商 (azure/aliyun/tencent)无--format, -fgithub / gitlab / jenkins / allgithub--output, -o输出目录./.github/workflows--name, -nworkflow 名称CI--python-versionPython 版本3.11--node-versionNode 版本20--go-versionGo 版本1.22--print-only仅打印,不写文件False
bash
pip install cicd-gen
# 或本地安装
cd cicd-templates-generator && pip install -e .
pyyamlcicd-gen.github/workflows/ci.yml)#yaml
name: CI
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: pip install -r requirements.txt pytest
- name: Run tests
run: pytest
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/app:latest
text
cicd-templates-generator/
├── cicd_gen/
│ ├── __init__.py
│ ├── cli.py # CLI 入口
│ └── generator/
│ ├── __init__.py # BaseGenerator
│ ├── github_actions.py # GitHub Actions 生成器
│ ├── gitlab_ci.py # GitLab CI 生成器
│ └── jenkins.py # Jenkinsfile 生成器
├── tests/
│ └── test_cicd_gen.py # 单元测试
├── setup.py
├── SKILL.md
└── DESIGN-cicd-templates-generator.md
当用户请求创建 CI/CD workflow 时:
cicd-gen CLI 生成对应 workflow--print-only 模式)bash
# 示例调用
cicd-gen python flask --test pytest --deploy docker --print-only