360 Secure SkillHub
360 安全技能中心

CI-CD

面向 Web、移动和后端应用的 CI/CD 技能:提供平台选型建议、GitHub Actions 工作流模板(templates.md)、移动端签名方案(Fastlane Match)、构建缓存配置、常见流水线陷阱与失败构建排查方法;明确不覆盖 Kubernetes、服务器配置与监控。

ivangdavila
ivangdavila
热度 66.68
最近更新 2026-05-11 16:28:05
分类:开发依赖:代码执行 / 读写文件 / 第三方 API应用场景:DevOps / 自动化脚本 / 工作流 / 调试排错

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add ci-cd
Metadata
name
CI-CD
description
Automate builds, tests, and deployments across web, mobile, and backend applications.

When to Use

Trigger on: automated deployment, continuous integration, pipeline setup, GitHub Actions, GitLab CI, build failing, deploy automatically, CI configuration, release automation.

Platform Selection

Stack Recommended Why
Web (Next.js, Nuxt, static) Vercel, Netlify Zero-config, auto-deploys, preview URLs
Mobile (iOS/Android/Flutter) Codemagic, Bitrise + Fastlane Pre-configured signing, app store upload
Backend/Docker GitHub Actions, GitLab CI Full control, self-hosted runners option
Monorepo Nx/Turborepo + GHA Affected detection, build caching

Decision tree: If platform handles deploy automatically (Vercel, Netlify) → skip custom CI. Only add GitHub Actions when you need tests, custom builds, or deploy to your own infra.

Quick Start Templates

For copy-paste workflows, see templates.md.

Common Pipeline Pitfalls

Mistake Impact Fix
Using latest image tags Builds break randomly Pin versions: node:20.11.0
Not caching dependencies +5-10 min per build Cache node_modules, .next/cache
Secrets in workflow files Leaked in logs/PRs Use platform secrets, OIDC for cloud
Missing timeout-minutes Stuck jobs burn budget Always set: timeout-minutes: 15
No concurrency control Redundant runs on rapid pushes Group by branch/PR
Building on every push Wasted resources Build on push to main, test on PRs

Mobile-Specific: Code Signing

The #1 pain point. iOS requires certificates + provisioning profiles. Android requires keystores.

The fix: Use Fastlane Match — stores certs/profiles in git repo, syncs across team and CI.

# One-time setup
fastlane match init
fastlane match appstore

# In CI
fastlane match appstore --readonly

For detailed mobile CI/CD patterns (iOS, Android, Flutter), see mobile.md.

Web-Specific: Build Caching

Next.js/Nuxt builds are slow without cache. The No Cache Detected warning = full rebuild.

# GitHub Actions: persist Next.js cache
- uses: actions/cache@v4
  with:
    path: .next/cache
    key: nextjs-${{ hashFiles('**/package-lock.json') }}

For framework-specific configs, see web.md.

Debugging Failed Builds

Error Pattern Likely Cause Check
Works locally, fails in CI Environment drift Node version, env vars, OS
Intermittent failures Flaky tests, resource limits Retry logic, increase timeout
ENOENT / file not found Build order, missing artifact Check needs: dependencies
Exit code 137 Out of memory Use larger runner or optimize
Certificate/signing errors Expired or mismatched creds Regenerate with Match/Fastlane

What This Doesn't Cover

  • Container orchestration (Kubernetes) → see k8s skill
  • Server configuration → see server skill
  • Monitoring and observability → see monitoring skill