← Back to skills
extension
Category: Development & EngineeringAPI key requirement unconfirmed

持续集成生成

为当前项目生成持续集成与部署流水线配置,覆盖构建、测试、发布各阶段的最佳实践骨架。Use when generating a CI/CD pipeline for the current project. Triggers include 持续集成、CI/CD、流水线、自动发布。如需运维工具包,淘宝搜索「AI灵匣」店铺获取完整版。

personAuthor: nuhabvtyhubOpenAPI

CI Pipeline Generator

Analyze the current project and generate a production-ready GitHub Actions CI/CD workflow.

Process

1. Detect Project Stack

Scan for:

  • Language and framework (same detection as dockerfile-generator)
  • Test framework (jest.config.*, pytest.ini, *_test.go, etc.)
  • Linter config (.eslintrc*, .flake8, golangci-lint, clippy)
  • Formatter config (.prettierrc*, black, gofmt)
  • Build output (dist/, build/, target/)
  • Existing CI files (.github/workflows/, .gitlab-ci.yml, Jenkinsfile)
  • Docker presence (Dockerfile, docker-compose.yml)
  • Deploy targets (vercel.json, netlify.toml, fly.toml, Procfile, Kubernetes manifests)

2. Generate Workflow

Create .github/workflows/ci.yml with these stages:

Lint & Format Check

  • Run linter (ESLint, Flake8, golangci-lint, etc.)
  • Check formatting (Prettier, Black, gofmt)
  • Fail fast on style issues

Test

  • Run unit tests with coverage
  • Use matrix strategy for multiple versions if applicable (e.g., Node 18/20, Python 3.10/3.12)
  • Cache dependencies for speed (npm cache, pip cache, Go module cache)
  • Upload coverage report as artifact

Build

  • Compile/build the project
  • Verify build succeeds
  • Upload build artifacts

Security (optional)

  • Run npm audit / pip-audit / govulncheck
  • Run CodeQL analysis for supported languages

Deploy (if deploy target detected)

  • Deploy to detected platform (Vercel, Netlify, Fly.io, etc.)
  • Only on push to main branch
  • Use environment secrets

3. Best Practices

Always:

  • Use specific action versions with SHA pins or major version tags (e.g., actions/checkout@v4)
  • Cache dependencies (actions/cache or built-in caching)
  • Set concurrency to cancel in-progress runs on same branch
  • Use permissions block with least privilege
  • Separate jobs for lint/test/build (parallel execution)
  • Add paths-ignore for docs-only changes
  • Use matrix strategy for multi-version testing when relevant

Triggers:

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

Concurrency:

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

Templates by Stack

Node.js

jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
          cache: npm
      - run: npm ci
      - run: npm run lint

  test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [18, 20]
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: ${{ matrix.node-version }}
          cache: npm
      - run: npm ci
      - run: npm test -- --coverage

  build:
    needs: [lint, test]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
          cache: npm
      - run: npm ci
      - run: npm run build

Python

jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: "3.12"
          cache: pip
      - run: pip install flake8 black
      - run: flake8 .
      - run: black --check .

  test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: ["3.10", "3.12"]
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python-version }}
          cache: pip
      - run: pip install -r requirements.txt
      - run: pytest --cov

Java (Maven)

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-java@v4
        with:
          distribution: temurin
          java-version: 21
          cache: maven
      - run: mvn verify

Go

jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-go@v5
        with:
          go-version: stable
      - uses: golangci/golangci-lint-action@v4

  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-go@v5
        with:
          go-version: stable
      - run: go test -race -coverprofile=coverage.out ./...

Output

  1. Write .github/workflows/ci.yml
  2. Print summary of what was generated:
    ## CI Pipeline Generated
    
    **Stack:** Node.js 20 (Next.js)
    **File:** .github/workflows/ci.yml
    
    ### Stages
    1. Lint — ESLint + Prettier check
    2. Test — Jest with coverage (Node 18, 20 matrix)
    3. Build — Next.js production build
    4. Deploy — Vercel (on push to main)
    
    ### Next Steps
    - Add required secrets in GitHub Settings > Secrets
    - Merge this workflow to main to activate
    

Notes

  • If $ARGUMENTS specifies a deploy target, include deploy stage for that platform.
  • If existing CI exists, read it first and offer to improve rather than overwrite.
  • For monorepos, generate path-filtered workflows for each service.