部署助手

高级效率

通过预检检查、部署脚本和回滚程序指导完成部署流程。

deploymentdevopsci-cdautomationproduction

Overview

The Deployment Assistant helps manage deployment processes by running pre-flight checks, executing deployment steps, and providing rollback procedures when needed.

SKILL.md Template

---
name: deploy
description: Guide deployment processes with pre-flight checks and rollback procedures. Use when deploying to staging or production environments.
disable-model-invocation: true
context: fork
---

Deploy $ARGUMENTS following this process:

## Pre-flight Checklist
Before deploying, verify:
- [ ] All tests passing
- [ ] No critical vulnerabilities
- [ ] Database migrations ready
- [ ] Environment variables configured
- [ ] Rollback plan documented

## Deployment Steps

### 1. Prepare Release
```bash
# Tag the release
git tag -a v$VERSION -m "Release $VERSION"

# Build production artifacts
npm run build

2. Database (if needed)

# Backup current database
pg_dump -Fc > backup_$(date +%Y%m%d).dump

# Run migrations
npm run migrate

3. Deploy Application

# Push to production
git push origin main --tags

# Or deploy to platform
vercel --prod
# railway up
# fly deploy

4. Verify Deployment

  • Health check endpoint responding
  • Key functionality tested
  • Error rates normal
  • Performance metrics stable

Rollback Procedure

If issues detected:

# Revert to previous version
git revert HEAD
git push origin main

# Restore database if needed
pg_restore -d myapp backup_YYYYMMDD.dump

Post-Deployment

  • Notify team in #deployments
  • Update changelog
  • Monitor for 30 minutes
  • Close related issues

## Example Deployment Session

```markdown
## Deploying MyApp v2.3.0 to Production

### Pre-flight Check Results
✅ All 847 tests passing
✅ No critical security issues
✅ Migration 20240115_add_oauth.sql ready
✅ Environment variables verified
✅ Previous version: v2.2.4

### Deployment Log

**14:30** Starting deployment
```bash
$ npm run build
✓ Build completed in 45s

14:31 Running migrations

$ npm run migrate
✓ Applied 1 migration

14:32 Deploying to production

$ vercel --prod
✓ Deployed to https://myapp.com

14:33 Running health checks ✅ /health returns 200 ✅ /api/status returns OK ✅ Authentication working

Post-Deployment Monitoring

  • Error rate: 0.01% (normal)
  • p95 latency: 120ms (normal)
  • Active users: 1,234 (expected)

Deployment Complete ✅

Duration: 4 minutes Rollback command: git revert abc1234 && git push


## Usage

/deploy production


Or:

/deploy staging v2.3.0-rc1


## Safety Features

- **Manual invocation only** - Never auto-deploys
- **Pre-flight checks** - Catches issues before deployment
- **Rollback ready** - Always have a way back
- **Audit trail** - Logs all deployment actions

## Customization

Add your deployment targets and procedures:

```yaml
---
name: deploy
description: Deploy to our infrastructure
---

Deployment targets:
- staging: deploy-staging.sh
- production: deploy-prod.sh (requires approval)
- canary: deploy-canary.sh (10% traffic)

相关技能