微算力 · API 导航与自营网关
API 接入 EN
未登录登录
🚀

生产级 CI/CD 流水线生成器

cicd-pipeline-generator · vv0.1.0
专业技能 安全 S+ 级 作者 Veeramanikandanr48 公开目录收录
1.2k 下载 346 安装 3.9k 收藏 31.2k 浏览

简介

基于 DevOps 最佳实践,为 Node.js 项目生成 GitHub Actions、GitLab CI 等平台的生产级自动化部署配置,支持 Vercel、AWS 等多平台一键部署。

原始描述

This skill should be used when creating or configuring CI/CD pipeline files for automated testing, building, and deployment. Use this for generating GitHub Actions workflows, GitLab CI configs, CircleCI configs, or other CI/CD platform configurations. Ideal for setting up automated pipelines for Node.js/Next.js applications, including linting, testing, building, and deploying to platforms like Vercel, Netlify, or AWS.

通过你的 Agent 添加

点「快速安装」复制一段指令,粘给你正在用的 Agent(Claude Code、Codex、OpenClaw 等),它会自己完成安装。

或者手动安装

Claude Codeunzip -o skill.zip -d ~/.claude/skills/cicd-pipeline-generator/
其它 Agent解压到它自己的 skills 目录,目录名用 cicd-pipeline-generator

包里是 SKILL.md 加作者附带的文件,解压后目录名就是技能名。 技能申请的权限由作者决定,装之前请确认它能读什么、能执行什么。

中文使用说明 来自收录源

核心功能

cicd-pipeline-generator 是一款专注于 CI/CD 流水线配置的文档型技能,主要面向现代 Web 开发者提供标准化、可复用的自动化部署解决方案。该技能的核心能力覆盖四大主流平台:GitHub Actions(原生集成最优)、GitLab CI/CD(复杂流水线场景)、CircleCI(Docker 工作流优化)以及 Jenkins(自托管高度定制)。

技能采用五阶段标准流水线架构:依赖安装 → 代码检查(ESLint/TypeScript)→ 测试执行(单元/集成测试+覆盖率)→ 生产构建 → 自动部署。特别针对 Node.js/Next.js 生态优化,内置 Vercel、Netlify、AWS S3+CloudFront 等平台的完整部署示例,包含矩阵构建、依赖缓存、分支差异化策略(feature/develop/main)等高级特性。

显著优势

  • 零安全风险:纯文档模板类型,无第三方依赖、无网络通信、无代码执行,六维安全检测全部满分(静态/动态/依赖/网络/隐私/威胁情报)
  • 即开即用:提供预置模板文件,支持一键复制到 .github/workflows/ 或 .gitlab-ci.yml
  • 部署全覆盖:从 Serverless 平台(Vercel/Netlify)到云服务(AWS),适配多种基础设施
  • 性能优化:内置智能缓存策略、并行化任务编排、快速失败机制
  • 安全最佳实践:强调 Secrets 管理、最小权限原则、密钥轮换,避免常见配置陷阱

局限与注意事项

  • 来源可信度 T3:维护者为个人开发者(veeramanikandanr48),版本 0.1.0 属早期发布,建议生产环境使用前先人工审查
  • 非动态执行:技能本身不自动创建文件,需用户手动复制模板并配置环境变量
  • 平台特定限制:部分高级功能(如 GitLab 手动审批、Vercel 组织级部署)需额外平台权限配置
  • 维护责任:生成配置后,后续的 Secret 管理、分支保护、安全扫描仍需用户自行实施

适合人群

  • 前端/全栈开发者(尤其 Next.js 技术栈)
  • 需要快速搭建 CI/CD 基础设施的初创团队
  • 希望标准化部署流程的技术负责人
  • 从手动部署迁移到自动化的遗留项目维护者

常规风险提醒

尽管技能本身 S+ 级安全,但生成的配置文件涉及生产环境密钥管理,用户需确保:VERCEL_TOKEN 等敏感信息仅存于平台 Secrets、定期轮换部署凭证、在 CI 中集成 npm audit 安全扫描、启用分支保护防止未授权主分支推送。

技能正文


name: cicd-pipeline-generator description: This skill should be used when creating or configuring CI/CD pipeline files for automated testing, building, and deployment. Use this for generating GitHub Actions workflows, GitLab CI configs, CircleCI configs, or other CI/CD platform configurations. Ideal for setting up automated pipelines for Node.js/Next.js applications, including linting, testing, building, and deploying to platforms like Vercel, Netlify, or AWS.

CI/CD Pipeline Generator

Overview

Generate production-ready CI/CD pipeline configuration files for various platforms (GitHub Actions, GitLab CI, CircleCI, Jenkins). This skill provides templates and guidance for setting up automated workflows that handle linting, testing, building, and deployment for modern web applications, particularly Node.js/Next.js projects.

Core Capabilities

1. Platform Selection

Choose the appropriate CI/CD platform based on project requirements:

  • GitHub Actions: Best for GitHub-hosted projects with native integration
  • GitLab CI/CD: Ideal for GitLab repositories with complex pipeline needs
  • CircleCI: Optimized for Docker workflows and fast build times
  • Jenkins: Suitable for self-hosted, highly customizable environments

Refer to references/platform-comparison.md for detailed platform comparisons, pros/cons, and use case recommendations.

2. Pipeline Configuration Generation

Generate pipeline configs following these principles:

Pipeline Stages

Structure pipelines with these standard stages:

  1. Install Dependencies

    • Checkout code from repository
    • Setup runtime environment (Node.js version)
    • Restore cached dependencies
    • Install dependencies with npm ci
    • Cache dependencies for future runs
  2. Lint

    • Run ESLint for code quality
    • Run TypeScript type checking
    • Fail fast on linting errors
  3. Test

    • Execute unit tests
    • Execute integration tests
    • Generate code coverage reports
    • Upload coverage to reporting services (Codecov, Coveralls)
  4. Build

    • Create production build
    • Verify build succeeds
    • Store build artifacts
  5. Deploy

    • Deploy to staging (develop branch)
    • Deploy to production (main branch)
    • Run post-deployment smoke tests

Caching Strategy

Implement effective caching to speed up builds:

# Cache node_modules based on package-lock.json
cache:
  key: ${{ hashFiles('package-lock.json') }}
  paths:
    - node_modules/
    - .npm/

Environment Variables

Configure necessary environment variables:

  • NODE_ENV: Set to production for builds
  • Platform-specific tokens: Store as secrets
  • Build-time variables: Pass to build process

3. Template Usage

Use provided templates from assets/ directory:

GitHub Actions Template (assets/github-actions-nodejs.yml):

  • Multi-job workflow with lint, test, build, deploy
  • Matrix builds for multiple Node.js versions (optional)
  • Vercel deployment integration
  • Artifact uploading
  • Code coverage reporting

GitLab CI Template (assets/gitlab-ci-nodejs.yml):

  • Multi-stage pipeline
  • Dependency caching
  • Manual production deployment
  • Automatic staging deployment
  • Coverage reporting

To use a template:

  1. Copy the appropriate template file
  2. Place in the correct location:
    • GitHub Actions: .github/workflows/ci.yml
    • GitLab CI: .gitlab-ci.yml
  3. Customize deployment targets, environment variables, and branch names
  4. Add required secrets to platform settings

4. Deployment Configuration

Vercel Deployment

For GitHub Actions:

- uses: amondnet/vercel-action@v25
  with:
    vercel-token: ${{ secrets.VERCEL_TOKEN }}
    vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
    vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}
    vercel-args: '--prod'

Required Secrets:

  • VERCEL_TOKEN: Get from Vercel account settings
  • VERCEL_ORG_ID: From Vercel project settings
  • VERCEL_PROJECT_ID: From Vercel project settings

Netlify Deployment

- run: |
    npm install -g netlify-cli
    netlify deploy --prod --dir=.next
  env:
    NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
    NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}

AWS S3 + CloudFront

- uses: aws-actions/configure-aws-credentials@v4
  with:
    aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
    aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
    aws-region: us-east-1

- run: |
    aws s3 sync .next/static s3://${{ secrets.S3_BUCKET }}/static
    aws cloudfront create-invalidation --distribution-id ${{ secrets.CF_DIST_ID }} --paths "/*"

5. Testing Integration

Configure test execution with proper reporting:

Jest Configuration:

- name: Run tests with coverage
  run: npm test -- --coverage --coverageReporters=text --coverageReporters=lcov

- name: Upload coverage
  uses: codecov/codecov-action@v4
  with:
    files: ./coverage/lcov.info
    flags: unittests

Fail Fast Strategy:

# Run quick tests first
jobs:
  lint:  # Fails in ~30 seconds
  test:  # Fails in ~2 minutes
  build: # Fails in ~5 minutes
    needs: [lint, test]
  deploy:
    needs: [build]

6. Branch-Based Workflows

Implement different behaviors per branch:

Feature Branches / PRs:

  • Run lint + test only
  • No deployment
  • Add PR comments with test results

Develop Branch:

  • Run lint + test + build
  • Deploy to staging environment
  • Automatic deployment

Main Branch:

  • Run lint + test + build
  • Deploy to production
  • Manual approval (optional)
  • Create release tags

Example:

deploy_staging:
  if: github.ref == 'refs/heads/develop'
  # Deploy to staging

deploy_production:
  if: github.ref == 'refs/heads/main'
  environment: production  # Requires manual approval
  # Deploy to production

Workflow Decision Tree

Follow this decision tree to generate the appropriate pipeline:

  1. Which platform?

    • GitHub → Use assets/github-actions-nodejs.yml
    • GitLab → Use assets/gitlab-ci-nodejs.yml
    • CircleCI/Jenkins → Adapt GitHub Actions template
    • Unsure → Consult references/platform-comparison.md
  2. What stages are needed?

    • Always include: Lint, Test, Build
    • Optional: Security scanning, E2E tests, performance tests
    • Add deployment stage if deploying from CI
  3. Which deployment platform?

    • Vercel → Use Vercel deployment examples
    • Netlify → Use Netlify CLI approach
    • AWS → Use AWS Actions/CLI
    • Custom → Implement custom deployment script
  4. What triggers?

    • On push to main/develop
    • On pull request
    • On tag creation
    • Manual workflow dispatch
  5. What environment variables needed?

    • Platform tokens (Vercel, Netlify, AWS)
    • API keys for external services
    • Build-time environment variables
    • Feature flags

Best Practices

Security

  • Store all secrets in platform secret management (never in code)
  • Use least-privilege tokens (read-only when possible)
  • Rotate secrets regularly
  • Audit secret access permissions
  • Never log secrets (use *** masking)

Performance

  • Cache dependencies aggressively
  • Parallelize independent jobs
  • Use matrix builds for multi-version testing
  • Fail fast: Run quick checks before slow ones
  • Optimize Docker layer caching

Reliability

  • Pin exact Node.js versions (18.x not just 18)
  • Commit lockfiles (package-lock.json)
  • Add retry logic for flaky external services
  • Set reasonable timeouts (10-15 minutes max)
  • Use continue-on-error for non-critical steps

Maintainability

  • Add comments explaining complex logic
  • Use reusable workflows/templates
  • Keep configs DRY (Don't Repeat Yourself)
  • Version control all pipeline changes
  • Document required secrets in README

Common Patterns

Multi-Environment Deployment

deploy_staging:
  environment: staging
  if: github.ref == 'refs/heads/develop'

deploy_production:
  environment: production
  if: github.ref == 'refs/heads/main'
  needs: [deploy_staging]

Matrix Testing

strategy:
  matrix:
    node-version: [16.x, 18.x, 20.x]
    os: [ubuntu-latest, windows-latest]

Conditional Steps

- name: Deploy
  if: github.event_name == 'push' && github.ref == 'refs/heads/main'
  run: npm run deploy

Artifact Management

- name: Upload build
  uses: actions/upload-artifact@v4
  with:
    name: build-output
    path: .next/
    retention-days: 7

- name: Download build
  uses: actions/download-artifact@v4
  with:
    name: build-output

Troubleshooting

Pipeline Failures

  1. Check action/job logs for error messages
  2. Verify environment variables and secrets are set
  3. Test commands locally before adding to pipeline
  4. Check for platform-specific issues in documentation

Slow Builds

  1. Verify cache is working (check cache hit/miss logs)
  2. Parallelize independent jobs
  3. Use faster runners if available
  4. Optimize dependency installation

Deployment Failures

  1. Verify deployment tokens are valid
  2. Check platform status pages
  3. Review deployment logs
  4. Test deployment commands locally

Resources

Templates (assets/)

  • github-actions-nodejs.yml: Complete GitHub Actions workflow
  • gitlab-ci-nodejs.yml: Complete GitLab CI pipeline

Reference Documentation (references/)

  • platform-comparison.md: Detailed comparison of CI/CD platforms, deployment targets, best practices, and common patterns

Example Usage

User Request: "Create a GitHub Actions workflow that runs tests and deploys to Vercel"

Steps:

  1. Copy assets/github-actions-nodejs.yml template
  2. Create .github/workflows/ directory if it doesn't exist
  3. Save as .github/workflows/ci.yml
  4. Update deployment section with Vercel credentials
  5. Add secrets to GitHub repository settings:
    • VERCEL_TOKEN
    • VERCEL_ORG_ID
    • VERCEL_PROJECT_ID
  6. Commit and push to trigger workflow

User Request: "Set up GitLab CI with staging and production environments"

Steps:

  1. Copy assets/gitlab-ci-nodejs.yml template
  2. Save as .gitlab-ci.yml in repository root
  3. Configure GitLab CI/CD variables:
    • VERCEL_TOKEN
    • Other deployment credentials
  4. Review manual approval settings for production
  5. Commit to trigger pipeline

Advanced Configuration

Monorepo Support

paths:
  - 'apps/frontend/**'
  - 'packages/**'

Scheduled Runs

on:
  schedule:
    - cron: '0 2 * * *'  # Daily at 2 AM

External Service Integration

- name: Notify Slack
  uses: 8398a7/action-slack@v3
  with:
    status: ${{ job.status }}
    webhook_url: ${{ secrets.SLACK_WEBHOOK }}

Security Scanning

- name: Run security audit
  run: npm audit --audit-level=moderate

- name: Check for vulnerabilities
  uses: snyk/actions/node@master
  env:
    SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}

正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。

标签

devopsautomationdevelopment-engineeringbackendtesting

同类 Skill