CI/CD Generator
Generate production-grade GitHub Actions workflows by analyzing the current project structure. Supports any stack, any deploy target.
Step 1: Detect Project Stack
Read the project root and identify what exists. Run these checks in parallel:
CODEBLOCK0
Build a detection summary:
| Signal | Stack |
|---|
| INLINECODE0 + INLINECODE1 | Next.js |
| INLINECODE2 + INLINECODE3 |
Nuxt |
|
package.json +
svelte.config.* | SvelteKit |
|
package.json (no framework config) | Generic Node.js |
|
requirements.txt or
pyproject.toml | Python |
|
go.mod | Go |
|
Cargo.toml | Rust |
|
Dockerfile | Docker build |
|
pnpm-workspace.yaml or
turbo.json | Monorepo |
|
vercel.json | Vercel deploy target |
Read package.json to extract:
- - Package manager (
packageManager field, or check for pnpm-lock.yaml, yarn.lock, bun.lockb, package-lock.json) - Scripts available (
lint, test, build, typecheck, format) - Node version requirements (
engines.node) - Framework and key dependencies
For Python, read pyproject.toml or requirements.txt to determine Python version and test framework (pytest, unittest).
Step 2: Ask the User
Present the detection results and ask:
- 1. Deploy target (if not obvious from vercel.json/railway.toml):
- Vercel (auto-deploy via git push, or CLI-based)
- Railway (auto-deploy or CLI)
- VPS via SSH (rsync + restart)
- Docker registry (GHCR, Docker Hub, ECR)
- None (CI only, no deploy)
- 2. Environments: Preview on PR + Production on main? Or just main?
- 3. Matrix testing: Test across multiple runtime versions? (e.g., Node 20 + 22, Python 3.11 + 3.12)
- 4. Additional checks: Security scanning? Dependency audit? Coverage reporting?
Step 3: Generate Workflows
Create .github/workflows/ directory and generate the appropriate workflow files.
Action Versions Reference (current as of 2026)
Always use these versions:
CODEBLOCK1
3A: Node.js / Next.js / Frontend Projects
File: INLINECODE30
CODEBLOCK2
Package manager install commands:
- - npm: INLINECODE31
- pnpm: INLINECODE32
- yarn: INLINECODE33
- bun: INLINECODE34
Cache key for setup-node:
- - npm: INLINECODE35
- pnpm: INLINECODE36
- yarn: INLINECODE37
For pnpm, add the corepack enable step before install:
CODEBLOCK3
If the project has no test script, omit the test job. If no lint script, omit lint. Same for typecheck. Always keep build.
3B: Python Projects
File: INLINECODE40
CODEBLOCK4
For pyproject.toml projects, replace pip install -r requirements.txt with pip install -e ".[dev]" or the appropriate extras.
For poetry projects:
CODEBLOCK5
3C: Docker Projects
File: INLINECODE43
CODEBLOCK6
For Docker Hub instead of GHCR:
CODEBLOCK7
For ECR:
CODEBLOCK8
3D: Monorepo Projects
For monorepos (Turborepo, pnpm workspaces, Nx), add path filters to avoid running everything on every change:
CODEBLOCK9
Adapt the app names and filter paths based on the actual monorepo structure. Read pnpm-workspace.yaml or turbo.json to discover workspace packages.
For Turborepo specifically, leverage turbo run:
CODEBLOCK10
Step 4: Generate Deploy Workflows
Vercel Deploy
If deploying via Vercel CLI (not git-push auto-deploy):
File: INLINECODE47
CODEBLOCK11
Required secrets: VERCEL_TOKEN, VERCEL_ORG_ID, INLINECODE50
If the project uses Vercel's git integration (auto-deploy on push), skip this workflow and tell the user -- CI workflow alone is sufficient since Vercel handles deploys automatically.
Railway Deploy
File: INLINECODE51
CODEBLOCK12
Required secrets: INLINECODE52
If Railway auto-deploys from GitHub, tell the user to enable "Wait for CI" in Railway service settings so it waits for the CI workflow to pass before deploying.
VPS via SSH
File: INLINECODE53
CODEBLOCK13
For rsync-based deploys (push built artifacts):
CODEBLOCK14
Required secrets: VPS_HOST, VPS_USER, VPS_SSH_KEY, INLINECODE57
Docker Registry Deploy
Use the Docker workflow from Step 3C. If deploying to a server after push, add a post-push job:
CODEBLOCK15
Step 5: Secrets Checklist
After generating workflows, output a checklist of secrets the user needs to configure in GitHub repo settings (Settings > Secrets and variables > Actions):
CODEBLOCK16
Only list secrets relevant to the chosen deploy target.
Step 6: Status Badge
Offer to add a CI status badge to the project README:
CODEBLOCK17
Read the git remote to determine OWNER/REPO automatically:
CODEBLOCK18
Rules
- 1. Never hardcode secrets. Always use
${{ secrets.NAME }} references. - Always use
concurrency groups to cancel redundant runs on the same branch/PR. - Always pin action versions to major tags (e.g.,
@v6), never @latest or @main. - Use
fail-fast: false in matrix builds so one version failing doesn't cancel others. - Separate CI from deploy. CI runs on PRs and pushes. Deploy only runs on main (or tags).
- Use GitHub Environments for production deploys to enable approval gates and env-specific secrets.
- Cache aggressively. Use setup-node/setup-python built-in cache for dependencies. Use GHA cache for Docker layers.
- Run lint/typecheck/test in parallel as separate jobs for faster feedback. Build depends on all passing.
- For monorepos, always add path filters. Never run all workspace CI on every file change.
- If workflows already exist (
.github/workflows/ is non-empty), read them first and ask the user whether to replace or extend. - Replace placeholder values (NODEVERSION, PACKAGEMANAGER, etc.) with actual detected values from the project. Never leave placeholders in the generated output.
- Only include jobs that the project supports. If there is no test script, no test job. If there is no lint script, no lint job. Don't generate dead jobs.
CI/CD 生成器
通过分析当前项目结构,生成生产级 GitHub Actions 工作流。支持任何技术栈、任何部署目标。
步骤 1:检测项目技术栈
读取项目根目录并识别存在的文件。并行运行以下检查:
Glob: package.json, pnpm-workspace.yaml, turbo.json, lerna.json
Glob: requirements.txt, pyproject.toml, setup.py, Pipfile, poetry.lock
Glob: Dockerfile, docker-compose.yml, docker-compose.yaml
Glob: go.mod, Cargo.toml, Gemfile, build.gradle, pom.xml
Glob: vercel.json, next.config., nuxt.config., svelte.config.*
Glob: .github/workflows/.yml, .github/workflows/.yaml
构建检测摘要:
| 信号 | 技术栈 |
|---|
| package.json + next.config. | Next.js |
| package.json + nuxt.config. |
Nuxt |
| package.json + svelte.config.* | SvelteKit |
| package.json(无框架配置) | 通用 Node.js |
| requirements.txt 或 pyproject.toml | Python |
| go.mod | Go |
| Cargo.toml | Rust |
| Dockerfile | Docker 构建 |
| pnpm-workspace.yaml 或 turbo.json | 单体仓库 |
| vercel.json | Vercel 部署目标 |
读取 package.json 提取:
- - 包管理器(packageManager 字段,或检查 pnpm-lock.yaml、yarn.lock、bun.lockb、package-lock.json)
- 可用脚本(lint、test、build、typecheck、format)
- Node 版本要求(engines.node)
- 框架和关键依赖
对于 Python,读取 pyproject.toml 或 requirements.txt 确定 Python 版本和测试框架(pytest、unittest)。
步骤 2:询问用户
展示检测结果并询问:
- 1. 部署目标(如果从 vercel.json/railway.toml 不明显):
- Vercel(通过 git push 自动部署,或基于 CLI)
- Railway(自动部署或 CLI)
- 通过 SSH 的 VPS(rsync + 重启)
- Docker 注册表(GHCR、Docker Hub、ECR)
- 无(仅 CI,无部署)
- 2. 环境:PR 预览 + main 生产?还是仅 main?
- 3. 矩阵测试:跨多个运行时版本测试?(例如 Node 20 + 22、Python 3.11 + 3.12)
- 4. 额外检查:安全扫描?依赖审计?覆盖率报告?
步骤 3:生成工作流
创建 .github/workflows/ 目录并生成适当的工作流文件。
操作版本参考(截至 2026 年)
始终使用这些版本:
yaml
actions/checkout@v6
actions/setup-node@v6
actions/setup-python@v6
actions/cache@v5
docker/setup-buildx-action@v3
docker/login-action@v3
docker/build-push-action@v6
docker/metadata-action@v5
3A:Node.js / Next.js / 前端项目
文件:.github/workflows/ci.yml
yaml
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: NODE_VERSION
cache: PACKAGE_MANAGER
- run: INSTALL_COMMAND
- run: LINT_COMMAND
typecheck:
name: Type Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: NODE_VERSION
cache: PACKAGE_MANAGER
- run: INSTALL_COMMAND
- run: TYPECHECK_COMMAND
test:
name: Test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [NODE_VERSIONS]
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
cache: PACKAGE_MANAGER
- run: INSTALL_COMMAND
- run: TEST_COMMAND
build:
name: Build
runs-on: ubuntu-latest
needs: [lint, typecheck, test]
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: NODE_VERSION
cache: PACKAGE_MANAGER
- run: INSTALL_COMMAND
- run: BUILD_COMMAND
包管理器安装命令:
- - npm:npm ci
- pnpm:corepack enable && pnpm install --frozen-lockfile
- yarn:corepack enable && yarn install --immutable
- bun:bun install --frozen-lockfile
setup-node 的缓存键:
- - npm:cache: npm
- pnpm:cache: pnpm
- yarn:cache: yarn
对于 pnpm,在安装前添加 corepack enable 步骤:
yaml
- - run: corepack enable
- uses: actions/setup-node@v6
with:
node-version: NODE_VERSION
cache: pnpm
如果项目没有 test 脚本,则省略 test 任务。如果没有 lint 脚本,则省略 lint。typecheck 同理。始终保留 build。
3B:Python 项目
文件:.github/workflows/ci.yml
yaml
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: PYTHON_VERSION
cache: pip
- run: pip install ruff
- run: ruff check .
test:
name: Test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [PYTHON_VERSIONS]
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
cache: pip
- run: pip install -r requirements.txt
- run: pytest
build:
name: Build
runs-on: ubuntu-latest
needs: [lint, test]
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: PYTHON_VERSION
cache: pip
- run: pip install -r requirements.txt
- run: python3 -m build
对于 pyproject.toml 项目,将 pip install -r requirements.txt 替换为 pip install -e .[dev] 或适当的 extras。
对于 poetry 项目:
yaml
- - run: pip install poetry
- run: poetry install
- run: poetry run pytest
3C:Docker 项目
文件:.github/workflows/docker.yml
yaml
name: Docker
on:
push:
branches: [main]
tags: [v*]
pull_request:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push:
name: Build & Push
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps: