AgentSkillsCN

ci-cd

GitHub Actions的CI/CD流水线模式,包括测试、构建、部署阶段、缓存、矩阵测试以及发布自动化。在设置或修改CI/CD流水线时使用此功能。

SKILL.md
--- frontmatter
name: ci-cd
description: CI/CD pipeline patterns for GitHub Actions including test, build, deploy stages, caching, matrix testing, and release automation. Use when setting up or modifying CI/CD pipelines.
compatibility: Requires GitHub repository
metadata:
  version: "1.0"

CI/CD

Decision Tree

code
Need CI/CD → What stack?
    ├─ Node/TypeScript → Use assets/ci-node.yml.template
    ├─ Python → Use assets/ci-python.yml.template
    └─ Multi-stack → Combine relevant templates

Pipeline Stages

code
Push/PR → Lint → Test → Build → Deploy (main only)

Key Patterns

Caching

yaml
- uses: actions/cache@v4
  with:
    path: ~/.npm
    key: npm-${{ hashFiles('**/package-lock.json') }}
    restore-keys: npm-

Branch Protection

  • Require PR reviews before merge
  • Require status checks to pass
  • Require branch is up to date
  • No force pushes to main

Secrets

  • Use GitHub Secrets (never echo in logs)
  • Use OIDC for cloud deployments (no static credentials)
  • Scope secrets to environments (staging, production)

Anti-Patterns

Anti-PatternFix
No cachingCache dependencies
npm install in CIUse npm ci (deterministic)
Skip tests for speedParallelize instead
Deploy on every pushUse tags/releases
Manual version bumpsAutomate with semantic-release

Templates: