@patricio0312rev/skillset 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/LICENSE +21 -0
- package/README.md +176 -0
- package/bin/cli.js +37 -0
- package/package.json +55 -0
- package/src/commands/init.js +301 -0
- package/src/index.js +168 -0
- package/src/lib/config.js +200 -0
- package/src/lib/generator.js +166 -0
- package/src/utils/display.js +95 -0
- package/src/utils/readme.js +196 -0
- package/src/utils/tool-specific.js +233 -0
- package/templates/ai-engineering/agent-orchestration-planner/ SKILL.md +266 -0
- package/templates/ai-engineering/cost-latency-optimizer/ SKILL.md +270 -0
- package/templates/ai-engineering/doc-to-vector-dataset-generator/ SKILL.md +239 -0
- package/templates/ai-engineering/evaluation-harness/ SKILL.md +219 -0
- package/templates/ai-engineering/guardrails-safety-filter-builder/ SKILL.md +226 -0
- package/templates/ai-engineering/llm-debugger/ SKILL.md +283 -0
- package/templates/ai-engineering/prompt-regression-tester/ SKILL.md +216 -0
- package/templates/ai-engineering/prompt-template-builder/ SKILL.md +393 -0
- package/templates/ai-engineering/rag-pipeline-builder/ SKILL.md +244 -0
- package/templates/ai-engineering/tool-function-schema-designer/ SKILL.md +219 -0
- package/templates/architecture/adr-writer/ SKILL.md +250 -0
- package/templates/architecture/api-versioning-deprecation-planner/ SKILL.md +331 -0
- package/templates/architecture/domain-model-boundaries-mapper/ SKILL.md +300 -0
- package/templates/architecture/migration-planner/ SKILL.md +376 -0
- package/templates/architecture/performance-budget-setter/ SKILL.md +318 -0
- package/templates/architecture/reliability-strategy-builder/ SKILL.md +286 -0
- package/templates/architecture/rfc-generator/ SKILL.md +362 -0
- package/templates/architecture/scalability-playbook/ SKILL.md +279 -0
- package/templates/architecture/system-design-generator/ SKILL.md +339 -0
- package/templates/architecture/tech-debt-prioritizer/ SKILL.md +329 -0
- package/templates/backend/api-contract-normalizer/ SKILL.md +487 -0
- package/templates/backend/api-endpoint-generator/ SKILL.md +415 -0
- package/templates/backend/auth-module-builder/ SKILL.md +99 -0
- package/templates/backend/background-jobs-designer/ SKILL.md +166 -0
- package/templates/backend/caching-strategist/ SKILL.md +190 -0
- package/templates/backend/error-handling-standardizer/ SKILL.md +174 -0
- package/templates/backend/rate-limiting-abuse-protection/ SKILL.md +147 -0
- package/templates/backend/rbac-permissions-builder/ SKILL.md +158 -0
- package/templates/backend/service-layer-extractor/ SKILL.md +269 -0
- package/templates/backend/webhook-receiver-hardener/ SKILL.md +211 -0
- package/templates/ci-cd/artifact-sbom-publisher/ SKILL.md +236 -0
- package/templates/ci-cd/caching-strategy-optimizer/ SKILL.md +195 -0
- package/templates/ci-cd/deployment-checklist-generator/ SKILL.md +381 -0
- package/templates/ci-cd/github-actions-pipeline-creator/ SKILL.md +348 -0
- package/templates/ci-cd/monorepo-ci-optimizer/ SKILL.md +298 -0
- package/templates/ci-cd/preview-environments-builder/ SKILL.md +187 -0
- package/templates/ci-cd/quality-gates-enforcer/ SKILL.md +342 -0
- package/templates/ci-cd/release-automation-builder/ SKILL.md +281 -0
- package/templates/ci-cd/rollback-workflow-builder/ SKILL.md +372 -0
- package/templates/ci-cd/secrets-env-manager/ SKILL.md +242 -0
- package/templates/db-management/backup-restore-runbook-generator/ SKILL.md +505 -0
- package/templates/db-management/data-integrity-auditor/ SKILL.md +505 -0
- package/templates/db-management/data-retention-archiving-planner/ SKILL.md +430 -0
- package/templates/db-management/data-seeding-fixtures-builder/ SKILL.md +375 -0
- package/templates/db-management/db-performance-watchlist/ SKILL.md +425 -0
- package/templates/db-management/etl-sync-job-builder/ SKILL.md +457 -0
- package/templates/db-management/multi-tenant-safety-checker/ SKILL.md +398 -0
- package/templates/db-management/prisma-migration-assistant/ SKILL.md +379 -0
- package/templates/db-management/schema-consistency-checker/ SKILL.md +440 -0
- package/templates/db-management/sql-query-optimizer/ SKILL.md +324 -0
- package/templates/foundation/changelog-writer/ SKILL.md +431 -0
- package/templates/foundation/code-formatter-installer/ SKILL.md +320 -0
- package/templates/foundation/codebase-summarizer/ SKILL.md +360 -0
- package/templates/foundation/dependency-doctor/ SKILL.md +163 -0
- package/templates/foundation/dev-environment-bootstrapper/ SKILL.md +259 -0
- package/templates/foundation/dev-onboarding-builder/ SKILL.md +556 -0
- package/templates/foundation/docs-starter-kit/ SKILL.md +574 -0
- package/templates/foundation/explaining-code/SKILL.md +13 -0
- package/templates/foundation/git-hygiene-enforcer/ SKILL.md +455 -0
- package/templates/foundation/project-scaffolder/ SKILL.md +65 -0
- package/templates/foundation/project-scaffolder/references/templates.md +126 -0
- package/templates/foundation/repo-structure-linter/ SKILL.md +0 -0
- package/templates/foundation/repo-structure-linter/references/conventions.md +98 -0
- package/templates/frontend/animation-micro-interaction-pack/ SKILL.md +41 -0
- package/templates/frontend/component-scaffold-generator/ SKILL.md +562 -0
- package/templates/frontend/design-to-component-translator/ SKILL.md +547 -0
- package/templates/frontend/form-wizard-builder/ SKILL.md +553 -0
- package/templates/frontend/frontend-refactor-planner/ SKILL.md +37 -0
- package/templates/frontend/i18n-frontend-implementer/ SKILL.md +44 -0
- package/templates/frontend/modal-drawer-system/ SKILL.md +377 -0
- package/templates/frontend/page-layout-builder/ SKILL.md +630 -0
- package/templates/frontend/state-ux-flow-builder/ SKILL.md +23 -0
- package/templates/frontend/table-builder/ SKILL.md +350 -0
- package/templates/performance/alerting-dashboard-builder/ SKILL.md +162 -0
- package/templates/performance/backend-latency-profiler-helper/ SKILL.md +108 -0
- package/templates/performance/caching-cdn-strategy-planner/ SKILL.md +150 -0
- package/templates/performance/capacity-planning-helper/ SKILL.md +242 -0
- package/templates/performance/core-web-vitals-tuner/ SKILL.md +126 -0
- package/templates/performance/incident-runbook-generator/ SKILL.md +162 -0
- package/templates/performance/load-test-scenario-builder/ SKILL.md +256 -0
- package/templates/performance/observability-setup/ SKILL.md +232 -0
- package/templates/performance/postmortem-writer/ SKILL.md +203 -0
- package/templates/performance/structured-logging-standardizer/ SKILL.md +122 -0
- package/templates/security/auth-security-reviewer/ SKILL.md +428 -0
- package/templates/security/dependency-vulnerability-triage/ SKILL.md +495 -0
- package/templates/security/input-validation-sanitization-auditor/ SKILL.md +76 -0
- package/templates/security/pii-redaction-logging-policy-builder/ SKILL.md +65 -0
- package/templates/security/rbac-policy-tester/ SKILL.md +80 -0
- package/templates/security/secrets-scanner/ SKILL.md +462 -0
- package/templates/security/secure-headers-csp-builder/ SKILL.md +404 -0
- package/templates/security/security-incident-playbook-generator/ SKILL.md +76 -0
- package/templates/security/security-pr-checklist-skill/ SKILL.md +62 -0
- package/templates/security/threat-model-generator/ SKILL.md +394 -0
- package/templates/testing/contract-testing-builder/ SKILL.md +492 -0
- package/templates/testing/coverage-strategist/ SKILL.md +436 -0
- package/templates/testing/e2e-test-builder/ SKILL.md +382 -0
- package/templates/testing/flaky-test-detective/ SKILL.md +416 -0
- package/templates/testing/integration-test-builder/ SKILL.md +525 -0
- package/templates/testing/mocking-assistant/ SKILL.md +383 -0
- package/templates/testing/snapshot-test-refactorer/ SKILL.md +375 -0
- package/templates/testing/test-data-factory-builder/ SKILL.md +449 -0
- package/templates/testing/test-reporting-triage-skill/ SKILL.md +469 -0
- package/templates/testing/unit-test-generator/ SKILL.md +548 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: caching-strategy-optimizer
|
|
3
|
+
description: Optimizes CI/CD pipeline speed by implementing effective caching for dependencies, Docker layers, build outputs, and test results. Provides before/after performance metrics and best practices. Use for "CI caching", "pipeline optimization", "build speed", or "cache strategy".
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Caching Strategy Optimizer
|
|
7
|
+
|
|
8
|
+
Dramatically speed up CI pipelines with intelligent caching.
|
|
9
|
+
|
|
10
|
+
## Cache Key Strategy
|
|
11
|
+
|
|
12
|
+
### Package Manager Caches
|
|
13
|
+
|
|
14
|
+
```yaml
|
|
15
|
+
# NPM - Hash package-lock.json
|
|
16
|
+
- uses: actions/cache@v3
|
|
17
|
+
with:
|
|
18
|
+
path: ~/.npm
|
|
19
|
+
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
|
|
20
|
+
restore-keys: |
|
|
21
|
+
${{ runner.os }}-npm-
|
|
22
|
+
|
|
23
|
+
# pnpm - More aggressive caching
|
|
24
|
+
- uses: pnpm/action-setup@v2
|
|
25
|
+
with:
|
|
26
|
+
version: 8
|
|
27
|
+
|
|
28
|
+
- uses: actions/cache@v3
|
|
29
|
+
with:
|
|
30
|
+
path: |
|
|
31
|
+
~/.pnpm-store
|
|
32
|
+
node_modules
|
|
33
|
+
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
|
|
34
|
+
restore-keys: |
|
|
35
|
+
${{ runner.os }}-pnpm-
|
|
36
|
+
|
|
37
|
+
# Python pip
|
|
38
|
+
- uses: actions/cache@v3
|
|
39
|
+
with:
|
|
40
|
+
path: ~/.cache/pip
|
|
41
|
+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
|
|
42
|
+
|
|
43
|
+
# Cargo/Rust
|
|
44
|
+
- uses: actions/cache@v3
|
|
45
|
+
with:
|
|
46
|
+
path: |
|
|
47
|
+
~/.cargo/bin/
|
|
48
|
+
~/.cargo/registry/index/
|
|
49
|
+
~/.cargo/registry/cache/
|
|
50
|
+
~/.cargo/git/db/
|
|
51
|
+
target/
|
|
52
|
+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Docker Layer Caching
|
|
56
|
+
|
|
57
|
+
### Using Buildx
|
|
58
|
+
|
|
59
|
+
```yaml
|
|
60
|
+
- name: Set up Docker Buildx
|
|
61
|
+
uses: docker/setup-buildx-action@v3
|
|
62
|
+
|
|
63
|
+
- name: Build with cache
|
|
64
|
+
uses: docker/build-push-action@v5
|
|
65
|
+
with:
|
|
66
|
+
context: .
|
|
67
|
+
cache-from: type=gha
|
|
68
|
+
cache-to: type=gha,mode=max
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Registry-based Cache
|
|
72
|
+
|
|
73
|
+
```yaml
|
|
74
|
+
- name: Build with registry cache
|
|
75
|
+
uses: docker/build-push-action@v5
|
|
76
|
+
with:
|
|
77
|
+
context: .
|
|
78
|
+
cache-from: type=registry,ref=myapp:buildcache
|
|
79
|
+
cache-to: type=registry,ref=myapp:buildcache,mode=max
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Build Output Caching
|
|
83
|
+
|
|
84
|
+
```yaml
|
|
85
|
+
# Next.js cache
|
|
86
|
+
- uses: actions/cache@v3
|
|
87
|
+
with:
|
|
88
|
+
path: |
|
|
89
|
+
${{ github.workspace }}/.next/cache
|
|
90
|
+
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
|
|
91
|
+
restore-keys: |
|
|
92
|
+
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
|
|
93
|
+
${{ runner.os }}-nextjs-
|
|
94
|
+
|
|
95
|
+
# Webpack cache
|
|
96
|
+
- uses: actions/cache@v3
|
|
97
|
+
with:
|
|
98
|
+
path: node_modules/.cache/webpack
|
|
99
|
+
key: ${{ runner.os }}-webpack-${{ hashFiles('webpack.config.js') }}-${{ hashFiles('src/**') }}
|
|
100
|
+
|
|
101
|
+
# TypeScript build cache
|
|
102
|
+
- uses: actions/cache@v3
|
|
103
|
+
with:
|
|
104
|
+
path: |
|
|
105
|
+
dist
|
|
106
|
+
tsconfig.tsbuildinfo
|
|
107
|
+
key: ${{ runner.os }}-tsc-${{ hashFiles('**/*.ts') }}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Test Results Caching
|
|
111
|
+
|
|
112
|
+
```yaml
|
|
113
|
+
# Jest cache
|
|
114
|
+
- uses: actions/cache@v3
|
|
115
|
+
with:
|
|
116
|
+
path: /tmp/jest_rt
|
|
117
|
+
key: ${{ runner.os }}-jest-${{ hashFiles('**/*.test.ts') }}
|
|
118
|
+
|
|
119
|
+
# Pytest cache
|
|
120
|
+
- uses: actions/cache@v3
|
|
121
|
+
with:
|
|
122
|
+
path: .pytest_cache
|
|
123
|
+
key: ${{ runner.os }}-pytest-${{ hashFiles('**/*test*.py') }}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Before/After Metrics
|
|
127
|
+
|
|
128
|
+
```markdown
|
|
129
|
+
## Before Optimization
|
|
130
|
+
|
|
131
|
+
- Total time: 12 minutes
|
|
132
|
+
- npm ci: 4 minutes
|
|
133
|
+
- Build: 5 minutes
|
|
134
|
+
- Tests: 3 minutes
|
|
135
|
+
|
|
136
|
+
## After Caching
|
|
137
|
+
|
|
138
|
+
- Total time: 3 minutes
|
|
139
|
+
- npm ci: 30 seconds (cache hit)
|
|
140
|
+
- Build: 1 minute (incremental)
|
|
141
|
+
- Tests: 1.5 minutes (cache hit)
|
|
142
|
+
|
|
143
|
+
**Improvement: 75% faster (12m → 3m)**
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Cache Hit Rate Monitoring
|
|
147
|
+
|
|
148
|
+
```yaml
|
|
149
|
+
- name: Check cache hit
|
|
150
|
+
id: cache
|
|
151
|
+
uses: actions/cache@v3
|
|
152
|
+
with:
|
|
153
|
+
path: node_modules
|
|
154
|
+
key: ${{ runner.os }}-deps-${{ hashFiles('package-lock.json') }}
|
|
155
|
+
|
|
156
|
+
- name: Log cache status
|
|
157
|
+
run: |
|
|
158
|
+
if [ "${{ steps.cache.outputs.cache-hit }}" == "true" ]; then
|
|
159
|
+
echo "✅ Cache hit - saved $(date -u -d @$SECONDS +%M:%S)"
|
|
160
|
+
else
|
|
161
|
+
echo "❌ Cache miss - installing from scratch"
|
|
162
|
+
fi
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Best Practices
|
|
166
|
+
|
|
167
|
+
1. **Precise keys**: Include all dependencies in hash
|
|
168
|
+
2. **Restore keys**: Fallback to partial matches
|
|
169
|
+
3. **Multiple paths**: Cache related files together
|
|
170
|
+
4. **Size limits**: GitHub Actions limit is 10GB
|
|
171
|
+
5. **Expiration**: Caches expire after 7 days
|
|
172
|
+
6. **Mode=max**: Docker cache mode for better hits
|
|
173
|
+
7. **Monitor hits**: Track cache effectiveness
|
|
174
|
+
|
|
175
|
+
## Common Pitfalls
|
|
176
|
+
|
|
177
|
+
❌ **Too generic keys**: `key: deps` (always hits)
|
|
178
|
+
✅ **Specific keys**: `key: deps-${{ hashFiles('package-lock.json') }}`
|
|
179
|
+
|
|
180
|
+
❌ **Missing restore-keys**: Cache miss on minor changes
|
|
181
|
+
✅ **Restore keys**: Partial match fallback
|
|
182
|
+
|
|
183
|
+
❌ **Caching node_modules with wrong lock file**
|
|
184
|
+
✅ **Match lock file**: Hash the right lockfile
|
|
185
|
+
|
|
186
|
+
## Output Checklist
|
|
187
|
+
|
|
188
|
+
- [ ] Package manager cache configured
|
|
189
|
+
- [ ] Build output cache
|
|
190
|
+
- [ ] Docker layer cache (if applicable)
|
|
191
|
+
- [ ] Test cache configured
|
|
192
|
+
- [ ] Cache keys use file hashes
|
|
193
|
+
- [ ] Restore keys for fallback
|
|
194
|
+
- [ ] Before/after metrics documented
|
|
195
|
+
- [ ] Cache hit monitoring
|
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: deployment-checklist-generator
|
|
3
|
+
description: Creates comprehensive deployment checklists with pre-deployment checks, smoke tests, verification steps, and sign-off workflows. Use for "deployment checklist", "release verification", "deployment runbook", or "production readiness".
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Deployment Checklist Generator
|
|
7
|
+
|
|
8
|
+
Ensure safe, reliable deployments with comprehensive checklists.
|
|
9
|
+
|
|
10
|
+
## Pre-Deployment Checklist
|
|
11
|
+
|
|
12
|
+
```markdown
|
|
13
|
+
# Pre-Deployment Checklist
|
|
14
|
+
|
|
15
|
+
## Code Quality
|
|
16
|
+
|
|
17
|
+
- [ ] All CI checks passing
|
|
18
|
+
- [ ] Code review approved (2+ reviewers)
|
|
19
|
+
- [ ] No known critical bugs
|
|
20
|
+
- [ ] Security scan passed
|
|
21
|
+
- [ ] Performance tests passed
|
|
22
|
+
|
|
23
|
+
## Dependencies
|
|
24
|
+
|
|
25
|
+
- [ ] All dependencies up to date
|
|
26
|
+
- [ ] No high/critical vulnerabilities
|
|
27
|
+
- [ ] Bundle size within budget
|
|
28
|
+
- [ ] Third-party services operational
|
|
29
|
+
|
|
30
|
+
## Database
|
|
31
|
+
|
|
32
|
+
- [ ] Migrations tested in staging
|
|
33
|
+
- [ ] Backup completed
|
|
34
|
+
- [ ] Rollback plan documented
|
|
35
|
+
- [ ] Data migration scripts reviewed
|
|
36
|
+
|
|
37
|
+
## Infrastructure
|
|
38
|
+
|
|
39
|
+
- [ ] Servers have capacity
|
|
40
|
+
- [ ] CDN cache invalidation plan
|
|
41
|
+
- [ ] Load balancer configured
|
|
42
|
+
- [ ] SSL certificates valid
|
|
43
|
+
|
|
44
|
+
## Documentation
|
|
45
|
+
|
|
46
|
+
- [ ] Changelog updated
|
|
47
|
+
- [ ] API docs updated (if changed)
|
|
48
|
+
- [ ] Deployment notes prepared
|
|
49
|
+
- [ ] Rollback instructions ready
|
|
50
|
+
|
|
51
|
+
## Communication
|
|
52
|
+
|
|
53
|
+
- [ ] Stakeholders notified
|
|
54
|
+
- [ ] Maintenance window scheduled (if needed)
|
|
55
|
+
- [ ] Support team briefed
|
|
56
|
+
- [ ] Status page prepared
|
|
57
|
+
|
|
58
|
+
## Deployment Window
|
|
59
|
+
|
|
60
|
+
- [ ] Off-peak hours selected
|
|
61
|
+
- [ ] Team available for monitoring
|
|
62
|
+
- [ ] Emergency contacts confirmed
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Deployment Workflow with Checks
|
|
66
|
+
|
|
67
|
+
```yaml
|
|
68
|
+
# .github/workflows/deploy.yml
|
|
69
|
+
name: Deploy to Production
|
|
70
|
+
|
|
71
|
+
on:
|
|
72
|
+
workflow_dispatch:
|
|
73
|
+
|
|
74
|
+
jobs:
|
|
75
|
+
pre-deploy-checks:
|
|
76
|
+
runs-on: ubuntu-latest
|
|
77
|
+
steps:
|
|
78
|
+
- uses: actions/checkout@v4
|
|
79
|
+
|
|
80
|
+
- name: Check branch
|
|
81
|
+
run: |
|
|
82
|
+
if [ "${{ github.ref }}" != "refs/heads/main" ]; then
|
|
83
|
+
echo "❌ Can only deploy from main branch"
|
|
84
|
+
exit 1
|
|
85
|
+
fi
|
|
86
|
+
|
|
87
|
+
- name: Verify CI passed
|
|
88
|
+
uses: actions/github-script@v7
|
|
89
|
+
with:
|
|
90
|
+
script: |
|
|
91
|
+
const checks = await github.rest.checks.listForRef({
|
|
92
|
+
owner: context.repo.owner,
|
|
93
|
+
repo: context.repo.repo,
|
|
94
|
+
ref: context.sha,
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const failed = checks.data.check_runs.filter(
|
|
98
|
+
check => check.conclusion === 'failure'
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
if (failed.length > 0) {
|
|
102
|
+
throw new Error(`CI checks failed: ${failed.map(c => c.name).join(', ')}`);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
- name: Check deployment window
|
|
106
|
+
run: |
|
|
107
|
+
HOUR=$(date +%H)
|
|
108
|
+
if [ $HOUR -ge 9 ] && [ $HOUR -le 17 ]; then
|
|
109
|
+
echo "⚠️ Deploying during business hours"
|
|
110
|
+
else
|
|
111
|
+
echo "✅ Deploying outside business hours"
|
|
112
|
+
fi
|
|
113
|
+
|
|
114
|
+
- name: Verify staging deployment
|
|
115
|
+
run: |
|
|
116
|
+
if ! curl -f https://staging.myapp.com/health; then
|
|
117
|
+
echo "❌ Staging is not healthy"
|
|
118
|
+
exit 1
|
|
119
|
+
fi
|
|
120
|
+
|
|
121
|
+
deploy:
|
|
122
|
+
needs: pre-deploy-checks
|
|
123
|
+
runs-on: ubuntu-latest
|
|
124
|
+
environment:
|
|
125
|
+
name: production
|
|
126
|
+
url: https://myapp.com
|
|
127
|
+
steps:
|
|
128
|
+
- uses: actions/checkout@v4
|
|
129
|
+
|
|
130
|
+
- name: Backup database
|
|
131
|
+
run: ./scripts/backup-db.sh
|
|
132
|
+
|
|
133
|
+
- name: Deploy
|
|
134
|
+
run: ./scripts/deploy.sh production
|
|
135
|
+
|
|
136
|
+
- name: Run smoke tests
|
|
137
|
+
run: ./scripts/smoke-tests.sh production
|
|
138
|
+
|
|
139
|
+
- name: Update status page
|
|
140
|
+
run: |
|
|
141
|
+
curl -X POST https://statuspage.io/api/v1/incidents \
|
|
142
|
+
-H "Authorization: Bearer ${{ secrets.STATUSPAGE_TOKEN }}" \
|
|
143
|
+
-d '{"name":"Deployment Complete","status":"resolved"}'
|
|
144
|
+
|
|
145
|
+
- name: Create deployment record
|
|
146
|
+
uses: actions/github-script@v7
|
|
147
|
+
with:
|
|
148
|
+
script: |
|
|
149
|
+
github.rest.repos.createDeployment({
|
|
150
|
+
owner: context.repo.owner,
|
|
151
|
+
repo: context.repo.repo,
|
|
152
|
+
ref: context.sha,
|
|
153
|
+
environment: 'production',
|
|
154
|
+
description: 'Production deployment',
|
|
155
|
+
});
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Smoke Test Script
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
#!/bin/bash
|
|
162
|
+
# scripts/smoke-tests.sh
|
|
163
|
+
|
|
164
|
+
ENVIRONMENT=$1
|
|
165
|
+
BASE_URL="https://${ENVIRONMENT}.myapp.com"
|
|
166
|
+
|
|
167
|
+
echo "🔍 Running smoke tests for $ENVIRONMENT..."
|
|
168
|
+
|
|
169
|
+
FAILED=0
|
|
170
|
+
|
|
171
|
+
# Test 1: Health endpoint
|
|
172
|
+
echo "Test 1: Health check"
|
|
173
|
+
if curl -f "$BASE_URL/health" | grep -q "ok"; then
|
|
174
|
+
echo "✅ Health check passed"
|
|
175
|
+
else
|
|
176
|
+
echo "❌ Health check failed"
|
|
177
|
+
FAILED=1
|
|
178
|
+
fi
|
|
179
|
+
|
|
180
|
+
# Test 2: User authentication
|
|
181
|
+
echo "Test 2: User login"
|
|
182
|
+
TOKEN=$(curl -s -X POST "$BASE_URL/api/auth/login" \
|
|
183
|
+
-H "Content-Type: application/json" \
|
|
184
|
+
-d '{"email":"test@example.com","password":"test123"}' \
|
|
185
|
+
| jq -r '.token')
|
|
186
|
+
|
|
187
|
+
if [ -n "$TOKEN" ] && [ "$TOKEN" != "null" ]; then
|
|
188
|
+
echo "✅ Login passed"
|
|
189
|
+
else
|
|
190
|
+
echo "❌ Login failed"
|
|
191
|
+
FAILED=1
|
|
192
|
+
fi
|
|
193
|
+
|
|
194
|
+
# Test 3: Critical API endpoints
|
|
195
|
+
echo "Test 3: API endpoints"
|
|
196
|
+
ENDPOINTS=("/api/users" "/api/products" "/api/orders")
|
|
197
|
+
|
|
198
|
+
for endpoint in "${ENDPOINTS[@]}"; do
|
|
199
|
+
STATUS=$(curl -s -o /dev/null -w "%{http_code}" \
|
|
200
|
+
-H "Authorization: Bearer $TOKEN" \
|
|
201
|
+
"$BASE_URL$endpoint")
|
|
202
|
+
|
|
203
|
+
if [ "$STATUS" == "200" ]; then
|
|
204
|
+
echo "✅ $endpoint: $STATUS"
|
|
205
|
+
else
|
|
206
|
+
echo "❌ $endpoint: $STATUS"
|
|
207
|
+
FAILED=1
|
|
208
|
+
fi
|
|
209
|
+
done
|
|
210
|
+
|
|
211
|
+
# Test 4: Database connectivity
|
|
212
|
+
echo "Test 4: Database check"
|
|
213
|
+
if curl -f "$BASE_URL/api/health/db" | grep -q "connected"; then
|
|
214
|
+
echo "✅ Database connected"
|
|
215
|
+
else
|
|
216
|
+
echo "❌ Database connection failed"
|
|
217
|
+
FAILED=1
|
|
218
|
+
fi
|
|
219
|
+
|
|
220
|
+
# Test 5: External services
|
|
221
|
+
echo "Test 5: External services"
|
|
222
|
+
SERVICES=("stripe" "sendgrid" "aws")
|
|
223
|
+
|
|
224
|
+
for service in "${SERVICES[@]}"; do
|
|
225
|
+
if curl -f "$BASE_URL/api/health/$service" | grep -q "ok"; then
|
|
226
|
+
echo "✅ $service: connected"
|
|
227
|
+
else
|
|
228
|
+
echo "❌ $service: connection failed"
|
|
229
|
+
FAILED=1
|
|
230
|
+
fi
|
|
231
|
+
done
|
|
232
|
+
|
|
233
|
+
if [ $FAILED -eq 1 ]; then
|
|
234
|
+
echo "❌ Smoke tests failed"
|
|
235
|
+
exit 1
|
|
236
|
+
fi
|
|
237
|
+
|
|
238
|
+
echo "✅ All smoke tests passed"
|
|
239
|
+
exit 0
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
## Post-Deployment Verification
|
|
243
|
+
|
|
244
|
+
```markdown
|
|
245
|
+
# Post-Deployment Verification
|
|
246
|
+
|
|
247
|
+
## Immediate Checks (0-5 minutes)
|
|
248
|
+
|
|
249
|
+
- [ ] Deployment completed successfully
|
|
250
|
+
- [ ] All smoke tests passed
|
|
251
|
+
- [ ] Health checks returning 200
|
|
252
|
+
- [ ] No 5xx errors in logs
|
|
253
|
+
- [ ] Application responding
|
|
254
|
+
|
|
255
|
+
## Short-term Monitoring (5-30 minutes)
|
|
256
|
+
|
|
257
|
+
- [ ] Error rate <1%
|
|
258
|
+
- [ ] Response time p95 <500ms
|
|
259
|
+
- [ ] CPU usage normal (<70%)
|
|
260
|
+
- [ ] Memory usage stable
|
|
261
|
+
- [ ] Database queries performing well
|
|
262
|
+
|
|
263
|
+
## Feature Verification
|
|
264
|
+
|
|
265
|
+
- [ ] Login/authentication working
|
|
266
|
+
- [ ] Checkout flow functional
|
|
267
|
+
- [ ] Search returning results
|
|
268
|
+
- [ ] Email notifications sending
|
|
269
|
+
- [ ] Payment processing working
|
|
270
|
+
|
|
271
|
+
## Metrics Dashboard
|
|
272
|
+
|
|
273
|
+
- [ ] Request volume normal
|
|
274
|
+
- [ ] Success rate >99%
|
|
275
|
+
- [ ] Latency within SLA
|
|
276
|
+
- [ ] No spike in errors
|
|
277
|
+
- [ ] User engagement stable
|
|
278
|
+
|
|
279
|
+
## Long-term Monitoring (1-24 hours)
|
|
280
|
+
|
|
281
|
+
- [ ] No user complaints
|
|
282
|
+
- [ ] Support tickets normal
|
|
283
|
+
- [ ] Revenue tracking normal
|
|
284
|
+
- [ ] All scheduled jobs running
|
|
285
|
+
- [ ] No memory leaks detected
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
## Sign-off Template
|
|
289
|
+
|
|
290
|
+
```yaml
|
|
291
|
+
- name: Request deployment approval
|
|
292
|
+
uses: trstringer/manual-approval@v1
|
|
293
|
+
with:
|
|
294
|
+
secret: ${{ secrets.GITHUB_TOKEN }}
|
|
295
|
+
approvers: tech-lead,ops-manager
|
|
296
|
+
minimum-approvals: 2
|
|
297
|
+
issue-title: "Approve Production Deployment"
|
|
298
|
+
issue-body: |
|
|
299
|
+
## Deployment Details
|
|
300
|
+
|
|
301
|
+
**Version:** ${{ github.ref_name }}
|
|
302
|
+
**Commit:** ${{ github.sha }}
|
|
303
|
+
**Changes:** See [changelog](CHANGELOG.md)
|
|
304
|
+
|
|
305
|
+
## Pre-deployment Checklist
|
|
306
|
+
- ✅ All CI checks passed
|
|
307
|
+
- ✅ Code review completed
|
|
308
|
+
- ✅ Security scan passed
|
|
309
|
+
- ✅ Staging verified
|
|
310
|
+
|
|
311
|
+
## Approval Required
|
|
312
|
+
This deployment requires approval from tech lead and ops manager.
|
|
313
|
+
|
|
314
|
+
**Approve:** Comment "approve" or "lgtm"
|
|
315
|
+
**Reject:** Comment "reject" or "block"
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
## Monitoring Dashboard
|
|
319
|
+
|
|
320
|
+
```markdown
|
|
321
|
+
# Deployment Monitoring Dashboard
|
|
322
|
+
|
|
323
|
+
## Key Metrics
|
|
324
|
+
|
|
325
|
+
### Health
|
|
326
|
+
|
|
327
|
+
- API Health: ✅ UP
|
|
328
|
+
- Database: ✅ Connected
|
|
329
|
+
- Cache: ✅ Connected
|
|
330
|
+
|
|
331
|
+
### Performance
|
|
332
|
+
|
|
333
|
+
- Requests/min: 1,234
|
|
334
|
+
- Error rate: 0.2%
|
|
335
|
+
- p50 latency: 120ms
|
|
336
|
+
- p95 latency: 450ms
|
|
337
|
+
- p99 latency: 1,200ms
|
|
338
|
+
|
|
339
|
+
### Infrastructure
|
|
340
|
+
|
|
341
|
+
- CPU: 45%
|
|
342
|
+
- Memory: 62%
|
|
343
|
+
- Disk: 38%
|
|
344
|
+
|
|
345
|
+
### Business Metrics
|
|
346
|
+
|
|
347
|
+
- Active users: 523
|
|
348
|
+
- Successful checkouts: 89/hour
|
|
349
|
+
- Revenue: $15,234/hour
|
|
350
|
+
|
|
351
|
+
## Alerts
|
|
352
|
+
|
|
353
|
+
No active alerts
|
|
354
|
+
|
|
355
|
+
## Recent Deployments
|
|
356
|
+
|
|
357
|
+
- v1.3.0: Deployed 5 minutes ago ✅
|
|
358
|
+
- v1.2.9: Deployed 2 days ago ✅
|
|
359
|
+
- v1.2.8: Rolled back 3 days ago ⚠️
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
## Best Practices
|
|
363
|
+
|
|
364
|
+
1. **Automated checks**: Enforce via CI/CD
|
|
365
|
+
2. **Manual review**: Critical deployments need approval
|
|
366
|
+
3. **Smoke tests**: Verify key functionality
|
|
367
|
+
4. **Gradual rollout**: Canary or blue-green
|
|
368
|
+
5. **Monitoring**: Watch metrics for 30 minutes
|
|
369
|
+
6. **Communication**: Keep stakeholders informed
|
|
370
|
+
7. **Rollback ready**: One-click rollback available
|
|
371
|
+
|
|
372
|
+
## Output Checklist
|
|
373
|
+
|
|
374
|
+
- [ ] Pre-deployment checklist
|
|
375
|
+
- [ ] Deployment workflow with gates
|
|
376
|
+
- [ ] Smoke test script
|
|
377
|
+
- [ ] Post-deployment verification
|
|
378
|
+
- [ ] Sign-off workflow
|
|
379
|
+
- [ ] Monitoring dashboard
|
|
380
|
+
- [ ] Communication templates
|
|
381
|
+
- [ ] Rollback instructions
|