opencode-metis 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.
Files changed (156) hide show
  1. package/README.md +140 -0
  2. package/dist/cli.cjs +63 -0
  3. package/dist/mcp-server.cjs +51 -0
  4. package/dist/plugin.cjs +4 -0
  5. package/dist/worker.cjs +224 -0
  6. package/opencode/agent/the-analyst/feature-prioritization.md +66 -0
  7. package/opencode/agent/the-analyst/market-research.md +77 -0
  8. package/opencode/agent/the-analyst/project-coordination.md +81 -0
  9. package/opencode/agent/the-analyst/requirements-analysis.md +77 -0
  10. package/opencode/agent/the-architect/compatibility-review.md +138 -0
  11. package/opencode/agent/the-architect/complexity-review.md +137 -0
  12. package/opencode/agent/the-architect/quality-review.md +67 -0
  13. package/opencode/agent/the-architect/security-review.md +127 -0
  14. package/opencode/agent/the-architect/system-architecture.md +119 -0
  15. package/opencode/agent/the-architect/system-documentation.md +83 -0
  16. package/opencode/agent/the-architect/technology-research.md +85 -0
  17. package/opencode/agent/the-chief.md +79 -0
  18. package/opencode/agent/the-designer/accessibility-implementation.md +101 -0
  19. package/opencode/agent/the-designer/design-foundation.md +74 -0
  20. package/opencode/agent/the-designer/interaction-architecture.md +75 -0
  21. package/opencode/agent/the-designer/user-research.md +70 -0
  22. package/opencode/agent/the-meta-agent.md +155 -0
  23. package/opencode/agent/the-platform-engineer/ci-cd-pipelines.md +109 -0
  24. package/opencode/agent/the-platform-engineer/containerization.md +106 -0
  25. package/opencode/agent/the-platform-engineer/data-architecture.md +81 -0
  26. package/opencode/agent/the-platform-engineer/dependency-review.md +144 -0
  27. package/opencode/agent/the-platform-engineer/deployment-automation.md +81 -0
  28. package/opencode/agent/the-platform-engineer/infrastructure-as-code.md +107 -0
  29. package/opencode/agent/the-platform-engineer/performance-tuning.md +82 -0
  30. package/opencode/agent/the-platform-engineer/pipeline-engineering.md +81 -0
  31. package/opencode/agent/the-platform-engineer/production-monitoring.md +105 -0
  32. package/opencode/agent/the-qa-engineer/exploratory-testing.md +66 -0
  33. package/opencode/agent/the-qa-engineer/performance-testing.md +81 -0
  34. package/opencode/agent/the-qa-engineer/quality-assurance.md +77 -0
  35. package/opencode/agent/the-qa-engineer/test-execution.md +66 -0
  36. package/opencode/agent/the-software-engineer/api-development.md +78 -0
  37. package/opencode/agent/the-software-engineer/component-development.md +79 -0
  38. package/opencode/agent/the-software-engineer/concurrency-review.md +141 -0
  39. package/opencode/agent/the-software-engineer/domain-modeling.md +66 -0
  40. package/opencode/agent/the-software-engineer/performance-optimization.md +113 -0
  41. package/opencode/command/analyze.md +149 -0
  42. package/opencode/command/constitution.md +178 -0
  43. package/opencode/command/debug.md +194 -0
  44. package/opencode/command/document.md +178 -0
  45. package/opencode/command/implement.md +225 -0
  46. package/opencode/command/refactor.md +207 -0
  47. package/opencode/command/review.md +229 -0
  48. package/opencode/command/simplify.md +267 -0
  49. package/opencode/command/specify.md +191 -0
  50. package/opencode/command/validate.md +224 -0
  51. package/opencode/skill/accessibility-design/SKILL.md +566 -0
  52. package/opencode/skill/accessibility-design/checklists/wcag-checklist.md +435 -0
  53. package/opencode/skill/agent-coordination/SKILL.md +224 -0
  54. package/opencode/skill/api-contract-design/SKILL.md +550 -0
  55. package/opencode/skill/api-contract-design/templates/graphql-schema-template.md +818 -0
  56. package/opencode/skill/api-contract-design/templates/rest-api-template.md +417 -0
  57. package/opencode/skill/architecture-design/SKILL.md +160 -0
  58. package/opencode/skill/architecture-design/examples/architecture-examples.md +170 -0
  59. package/opencode/skill/architecture-design/template.md +749 -0
  60. package/opencode/skill/architecture-design/validation.md +99 -0
  61. package/opencode/skill/architecture-selection/SKILL.md +522 -0
  62. package/opencode/skill/architecture-selection/examples/adrs/001-example-adr.md +71 -0
  63. package/opencode/skill/architecture-selection/examples/architecture-patterns.md +239 -0
  64. package/opencode/skill/bug-diagnosis/SKILL.md +235 -0
  65. package/opencode/skill/code-quality-review/SKILL.md +337 -0
  66. package/opencode/skill/code-quality-review/examples/anti-patterns.md +629 -0
  67. package/opencode/skill/code-quality-review/reference.md +322 -0
  68. package/opencode/skill/code-review/SKILL.md +363 -0
  69. package/opencode/skill/code-review/reference.md +450 -0
  70. package/opencode/skill/codebase-analysis/SKILL.md +139 -0
  71. package/opencode/skill/codebase-navigation/SKILL.md +227 -0
  72. package/opencode/skill/codebase-navigation/examples/exploration-patterns.md +263 -0
  73. package/opencode/skill/coding-conventions/SKILL.md +178 -0
  74. package/opencode/skill/coding-conventions/checklists/accessibility-checklist.md +176 -0
  75. package/opencode/skill/coding-conventions/checklists/performance-checklist.md +154 -0
  76. package/opencode/skill/coding-conventions/checklists/security-checklist.md +127 -0
  77. package/opencode/skill/constitution-validation/SKILL.md +315 -0
  78. package/opencode/skill/constitution-validation/examples/CONSTITUTION.md +202 -0
  79. package/opencode/skill/constitution-validation/reference/rule-patterns.md +328 -0
  80. package/opencode/skill/constitution-validation/template.md +115 -0
  81. package/opencode/skill/context-preservation/SKILL.md +445 -0
  82. package/opencode/skill/data-modeling/SKILL.md +385 -0
  83. package/opencode/skill/data-modeling/templates/schema-design-template.md +268 -0
  84. package/opencode/skill/deployment-pipeline-design/SKILL.md +579 -0
  85. package/opencode/skill/deployment-pipeline-design/templates/pipeline-template.md +633 -0
  86. package/opencode/skill/documentation-extraction/SKILL.md +259 -0
  87. package/opencode/skill/documentation-sync/SKILL.md +431 -0
  88. package/opencode/skill/domain-driven-design/SKILL.md +509 -0
  89. package/opencode/skill/domain-driven-design/examples/ddd-patterns.md +688 -0
  90. package/opencode/skill/domain-driven-design/reference.md +465 -0
  91. package/opencode/skill/drift-detection/SKILL.md +383 -0
  92. package/opencode/skill/drift-detection/reference.md +340 -0
  93. package/opencode/skill/error-recovery/SKILL.md +162 -0
  94. package/opencode/skill/error-recovery/examples/error-patterns.md +484 -0
  95. package/opencode/skill/feature-prioritization/SKILL.md +419 -0
  96. package/opencode/skill/feature-prioritization/examples/rice-template.md +139 -0
  97. package/opencode/skill/feature-prioritization/reference.md +256 -0
  98. package/opencode/skill/git-workflow/SKILL.md +453 -0
  99. package/opencode/skill/implementation-planning/SKILL.md +215 -0
  100. package/opencode/skill/implementation-planning/examples/phase-examples.md +217 -0
  101. package/opencode/skill/implementation-planning/template.md +220 -0
  102. package/opencode/skill/implementation-planning/validation.md +88 -0
  103. package/opencode/skill/implementation-verification/SKILL.md +272 -0
  104. package/opencode/skill/knowledge-capture/SKILL.md +265 -0
  105. package/opencode/skill/knowledge-capture/reference/knowledge-capture.md +402 -0
  106. package/opencode/skill/knowledge-capture/reference.md +444 -0
  107. package/opencode/skill/knowledge-capture/templates/domain-template.md +325 -0
  108. package/opencode/skill/knowledge-capture/templates/interface-template.md +255 -0
  109. package/opencode/skill/knowledge-capture/templates/pattern-template.md +144 -0
  110. package/opencode/skill/observability-design/SKILL.md +291 -0
  111. package/opencode/skill/observability-design/references/monitoring-patterns.md +461 -0
  112. package/opencode/skill/pattern-detection/SKILL.md +171 -0
  113. package/opencode/skill/pattern-detection/examples/common-patterns.md +359 -0
  114. package/opencode/skill/performance-analysis/SKILL.md +266 -0
  115. package/opencode/skill/performance-analysis/references/profiling-tools.md +499 -0
  116. package/opencode/skill/requirements-analysis/SKILL.md +139 -0
  117. package/opencode/skill/requirements-analysis/examples/good-prd.md +66 -0
  118. package/opencode/skill/requirements-analysis/template.md +177 -0
  119. package/opencode/skill/requirements-analysis/validation.md +69 -0
  120. package/opencode/skill/requirements-elicitation/SKILL.md +518 -0
  121. package/opencode/skill/requirements-elicitation/examples/interview-questions.md +226 -0
  122. package/opencode/skill/requirements-elicitation/examples/user-stories.md +414 -0
  123. package/opencode/skill/safe-refactoring/SKILL.md +312 -0
  124. package/opencode/skill/safe-refactoring/reference/code-smells.md +347 -0
  125. package/opencode/skill/security-assessment/SKILL.md +421 -0
  126. package/opencode/skill/security-assessment/checklists/security-review-checklist.md +285 -0
  127. package/opencode/skill/specification-management/SKILL.md +143 -0
  128. package/opencode/skill/specification-management/readme-template.md +32 -0
  129. package/opencode/skill/specification-management/reference.md +115 -0
  130. package/opencode/skill/specification-management/spec.py +229 -0
  131. package/opencode/skill/specification-validation/SKILL.md +397 -0
  132. package/opencode/skill/specification-validation/reference/3cs-framework.md +306 -0
  133. package/opencode/skill/specification-validation/reference/ambiguity-detection.md +132 -0
  134. package/opencode/skill/specification-validation/reference/constitution-validation.md +301 -0
  135. package/opencode/skill/specification-validation/reference/drift-detection.md +383 -0
  136. package/opencode/skill/task-delegation/SKILL.md +607 -0
  137. package/opencode/skill/task-delegation/examples/file-coordination.md +495 -0
  138. package/opencode/skill/task-delegation/examples/parallel-research.md +337 -0
  139. package/opencode/skill/task-delegation/examples/sequential-build.md +504 -0
  140. package/opencode/skill/task-delegation/reference.md +825 -0
  141. package/opencode/skill/tech-stack-detection/SKILL.md +89 -0
  142. package/opencode/skill/tech-stack-detection/references/framework-signatures.md +598 -0
  143. package/opencode/skill/technical-writing/SKILL.md +190 -0
  144. package/opencode/skill/technical-writing/templates/adr-template.md +205 -0
  145. package/opencode/skill/technical-writing/templates/system-doc-template.md +380 -0
  146. package/opencode/skill/test-design/SKILL.md +464 -0
  147. package/opencode/skill/test-design/examples/test-pyramid.md +724 -0
  148. package/opencode/skill/testing/SKILL.md +213 -0
  149. package/opencode/skill/testing/examples/test-pyramid.md +724 -0
  150. package/opencode/skill/user-insight-synthesis/SKILL.md +576 -0
  151. package/opencode/skill/user-insight-synthesis/templates/research-plan-template.md +217 -0
  152. package/opencode/skill/user-research/SKILL.md +508 -0
  153. package/opencode/skill/user-research/examples/interview-questions.md +265 -0
  154. package/opencode/skill/user-research/examples/personas.md +267 -0
  155. package/opencode/skill/vibe-security/SKILL.md +654 -0
  156. package/package.json +45 -0
@@ -0,0 +1,579 @@
1
+ ---
2
+ name: deployment-pipeline-design
3
+ description: "Pipeline design, deployment strategies (blue-green, canary, rolling), and CI/CD platform patterns. Use when designing pipelines, implementing deployments, configuring quality gates, or setting up automated release workflows."
4
+ license: MIT
5
+ compatibility: opencode
6
+ metadata:
7
+ category: infrastructure
8
+ version: "1.0"
9
+ ---
10
+
11
+ # Deployment Pipeline Design
12
+
13
+ Roleplay as a CI/CD pipeline design specialist for creating reliable, secure deployment workflows. Covers pipeline architecture, deployment strategies, quality gates, and platform-specific patterns for GitHub Actions and GitLab CI.
14
+
15
+ DeploymentPipelineDesign {
16
+ Activation {
17
+ Designing new CI/CD pipelines from scratch
18
+ Implementing deployment strategies (blue-green, canary, rolling)
19
+ Setting up quality gates and approval workflows
20
+ Configuring GitHub Actions or GitLab CI pipelines
21
+ Implementing automated rollback mechanisms
22
+ Creating multi-environment deployment workflows
23
+ Integrating security scanning into pipelines
24
+ }
25
+
26
+ Constraints {
27
+ 1. Fail fast - run quick checks before slow ones
28
+ 2. Build once, deploy everywhere (immutable artifacts)
29
+ 3. Environment parity - dev, staging, prod should be identical
30
+ 4. Always have a rollback plan
31
+ 5. Never skip security scanning for production deployments
32
+ }
33
+
34
+ PipelineArchitecture {
35
+ Stages {
36
+ ```
37
+ Build -> Test -> Analyze -> Package -> Deploy -> Verify
38
+ ```
39
+
40
+ | Stage | Purpose | Failure Action |
41
+ |-------|---------|----------------|
42
+ | Build | Compile code, resolve dependencies | Fail fast, notify developer |
43
+ | Test | Unit tests, integration tests | Block deployment |
44
+ | Analyze | SAST, linting, code coverage | Block or warn based on threshold |
45
+ | Package | Create artifacts, container images | Fail fast |
46
+ | Deploy | Push to environment | Rollback on failure |
47
+ | Verify | Smoke tests, health checks | Trigger rollback |
48
+ }
49
+
50
+ DesignPrinciples {
51
+ 1. Fail Fast: Run quick checks (lint, unit tests) before slow ones
52
+ 2. Parallel Execution: Run independent jobs concurrently
53
+ 3. Artifact Caching: Cache dependencies between runs
54
+ 4. Immutable Artifacts: Build once, deploy everywhere
55
+ 5. Environment Parity: Dev, staging, and prod should be identical
56
+ }
57
+ }
58
+
59
+ DeploymentStrategies {
60
+ BlueGreenDeployment {
61
+ Description: "Two identical production environments where traffic switches instantly"
62
+
63
+ ```
64
+ Load Balancer
65
+ |
66
+ +------------+------------+
67
+ | |
68
+ [Blue v1.0] [Green v1.1]
69
+ (active) (standby)
70
+ ```
71
+
72
+ WhenToUse {
73
+ Zero-downtime requirements
74
+ Need instant rollback capability
75
+ Sufficient infrastructure budget for duplicate environments
76
+ }
77
+
78
+ ImplementationSteps {
79
+ 1. Deploy new version to inactive environment (Green)
80
+ 2. Run smoke tests against Green
81
+ 3. Switch load balancer to Green
82
+ 4. Monitor for issues
83
+ 5. Keep Blue running for quick rollback
84
+ 6. After confidence period, Blue becomes next deployment target
85
+ }
86
+
87
+ Rollback: "Switch load balancer back to Blue (seconds)"
88
+ }
89
+
90
+ CanaryDeployment {
91
+ Description: "Gradually shift traffic from old version to new version"
92
+
93
+ ```
94
+ Traffic Distribution Over Time:
95
+
96
+ T0: [====== v1.0 100% ======]
97
+ T1: [=== v1.0 95% ===][v1.1 5%]
98
+ T2: [== v1.0 75% ==][= v1.1 25% =]
99
+ T3: [= v1.0 50% =][== v1.1 50% ==]
100
+ T4: [====== v1.1 100% ======]
101
+ ```
102
+
103
+ WhenToUse {
104
+ High-risk deployments
105
+ Need to validate with real traffic
106
+ Want gradual rollout with monitoring
107
+ }
108
+
109
+ TrafficProgression {
110
+ 1. 5% for 15 minutes - validate basic functionality
111
+ 2. 25% for 30 minutes - monitor error rates
112
+ 3. 50% for 1 hour - check performance metrics
113
+ 4. 100% - full rollout
114
+ }
115
+
116
+ RollbackTriggers {
117
+ Error rate exceeds baseline + threshold
118
+ Latency exceeds acceptable limits
119
+ Health check failures
120
+ }
121
+ }
122
+
123
+ RollingDeployment {
124
+ Description: "Replace instances incrementally, one batch at a time"
125
+
126
+ ```
127
+ Instance Pool (5 instances):
128
+
129
+ T0: [v1.0] [v1.0] [v1.0] [v1.0] [v1.0]
130
+ T1: [v1.1] [v1.0] [v1.0] [v1.0] [v1.0]
131
+ T2: [v1.1] [v1.1] [v1.0] [v1.0] [v1.0]
132
+ T3: [v1.1] [v1.1] [v1.1] [v1.0] [v1.0]
133
+ T4: [v1.1] [v1.1] [v1.1] [v1.1] [v1.0]
134
+ T5: [v1.1] [v1.1] [v1.1] [v1.1] [v1.1]
135
+ ```
136
+
137
+ WhenToUse {
138
+ Limited infrastructure resources
139
+ Can tolerate mixed versions during deployment
140
+ Stateless applications
141
+ }
142
+
143
+ ConfigurationParameters {
144
+ maxUnavailable: "How many instances can be down simultaneously"
145
+ maxSurge: "How many extra instances during deployment"
146
+ minReadySeconds: "Wait time before considering instance healthy"
147
+ }
148
+ }
149
+
150
+ FeatureFlags {
151
+ Description: "Decouple deployment from release - deploy code without activating features"
152
+
153
+ ```javascript
154
+ if (featureFlags.isEnabled('new-checkout', user)) {
155
+ return newCheckoutFlow(cart);
156
+ } else {
157
+ return legacyCheckoutFlow(cart);
158
+ }
159
+ ```
160
+
161
+ WhenToUse {
162
+ Long-running feature development
163
+ A/B testing requirements
164
+ Gradual feature rollouts
165
+ Kill switch for problematic features
166
+ }
167
+
168
+ Rollback: "Disable flag (no deployment required)"
169
+ }
170
+ }
171
+
172
+ QualityGates {
173
+ RequiredGates {
174
+ | Gate | Threshold | Block Deploy? |
175
+ |------|-----------|---------------|
176
+ | Unit Tests | 100% pass | Yes |
177
+ | Integration Tests | 100% pass | Yes |
178
+ | Code Coverage | >= 80% | Yes |
179
+ | Security Scan (Critical) | 0 findings | Yes |
180
+ | Security Scan (High) | 0 new findings | Configurable |
181
+ | Dependency Vulnerabilities | 0 critical | Yes |
182
+ }
183
+
184
+ ManualApprovalGates {
185
+ ```yaml
186
+ # Conceptual flow
187
+ stages:
188
+ - test
189
+ - deploy-staging
190
+ - approval # Manual gate
191
+ - deploy-prod
192
+ - verify
193
+ ```
194
+
195
+ Requirements {
196
+ At least 2 approvers for production
197
+ No self-approval allowed
198
+ Time-boxed approval windows
199
+ Audit trail of approvals
200
+ }
201
+ }
202
+ }
203
+
204
+ GitHubActionsPatterns {
205
+ BasicPipelineStructure {
206
+ ```yaml
207
+ name: CI/CD Pipeline
208
+
209
+ on:
210
+ push:
211
+ branches: [main, develop]
212
+ pull_request:
213
+ branches: [main]
214
+
215
+ concurrency:
216
+ group: ${{ github.workflow }}-${{ github.ref }}
217
+ cancel-in-progress: true
218
+
219
+ jobs:
220
+ build:
221
+ runs-on: ubuntu-latest
222
+ steps:
223
+ - uses: actions/checkout@v4
224
+ - uses: actions/setup-node@v4
225
+ with:
226
+ node-version: '20'
227
+ cache: 'npm'
228
+ - run: npm ci
229
+ - run: npm run build
230
+ - uses: actions/upload-artifact@v4
231
+ with:
232
+ name: build
233
+ path: dist/
234
+
235
+ test:
236
+ needs: build
237
+ runs-on: ubuntu-latest
238
+ steps:
239
+ - uses: actions/checkout@v4
240
+ - uses: actions/download-artifact@v4
241
+ with:
242
+ name: build
243
+ path: dist/
244
+ - run: npm ci
245
+ - run: npm test
246
+
247
+ deploy-staging:
248
+ needs: test
249
+ if: github.ref == 'refs/heads/main'
250
+ environment: staging
251
+ runs-on: ubuntu-latest
252
+ steps:
253
+ - uses: actions/download-artifact@v4
254
+ with:
255
+ name: build
256
+ - run: ./deploy.sh staging
257
+
258
+ deploy-prod:
259
+ needs: deploy-staging
260
+ if: github.ref == 'refs/heads/main'
261
+ environment: production
262
+ runs-on: ubuntu-latest
263
+ steps:
264
+ - uses: actions/download-artifact@v4
265
+ with:
266
+ name: build
267
+ - run: ./deploy.sh production
268
+ ```
269
+ }
270
+
271
+ MatrixBuilds {
272
+ ```yaml
273
+ jobs:
274
+ test:
275
+ strategy:
276
+ fail-fast: false
277
+ matrix:
278
+ os: [ubuntu-latest, windows-latest, macos-latest]
279
+ node: [18, 20, 22]
280
+ runs-on: ${{ matrix.os }}
281
+ steps:
282
+ - uses: actions/checkout@v4
283
+ - uses: actions/setup-node@v4
284
+ with:
285
+ node-version: ${{ matrix.node }}
286
+ - run: npm ci
287
+ - run: npm test
288
+ ```
289
+ }
290
+
291
+ ReusableWorkflows {
292
+ ```yaml
293
+ # .github/workflows/deploy-reusable.yml
294
+ name: Reusable Deploy
295
+
296
+ on:
297
+ workflow_call:
298
+ inputs:
299
+ environment:
300
+ required: true
301
+ type: string
302
+ secrets:
303
+ DEPLOY_KEY:
304
+ required: true
305
+
306
+ jobs:
307
+ deploy:
308
+ environment: ${{ inputs.environment }}
309
+ runs-on: ubuntu-latest
310
+ steps:
311
+ - run: ./deploy.sh ${{ inputs.environment }}
312
+ env:
313
+ DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
314
+ ```
315
+
316
+ CallingWorkflow {
317
+ ```yaml
318
+ jobs:
319
+ deploy-staging:
320
+ uses: ./.github/workflows/deploy-reusable.yml
321
+ with:
322
+ environment: staging
323
+ secrets:
324
+ DEPLOY_KEY: ${{ secrets.STAGING_DEPLOY_KEY }}
325
+ ```
326
+ }
327
+ }
328
+
329
+ EnvironmentProtectionRules {
330
+ Required reviewers for production
331
+ Wait timer (e.g., 15 minutes before prod deploy)
332
+ Restrict to specific branches
333
+ Required status checks
334
+ }
335
+ }
336
+
337
+ GitLabCIPatterns {
338
+ BasicPipelineStructure {
339
+ ```yaml
340
+ stages:
341
+ - build
342
+ - test
343
+ - deploy
344
+
345
+ variables:
346
+ NODE_VERSION: "20"
347
+
348
+ default:
349
+ image: node:${NODE_VERSION}
350
+ cache:
351
+ paths:
352
+ - node_modules/
353
+
354
+ build:
355
+ stage: build
356
+ script:
357
+ - npm ci
358
+ - npm run build
359
+ artifacts:
360
+ paths:
361
+ - dist/
362
+ expire_in: 1 hour
363
+
364
+ test:unit:
365
+ stage: test
366
+ script:
367
+ - npm ci
368
+ - npm run test:unit
369
+ coverage: '/Coverage: \d+\.\d+%/'
370
+
371
+ test:integration:
372
+ stage: test
373
+ services:
374
+ - postgres:15
375
+ variables:
376
+ POSTGRES_DB: test
377
+ POSTGRES_USER: test
378
+ POSTGRES_PASSWORD: test
379
+ script:
380
+ - npm ci
381
+ - npm run test:integration
382
+
383
+ deploy:staging:
384
+ stage: deploy
385
+ environment:
386
+ name: staging
387
+ url: https://staging.example.com
388
+ script:
389
+ - ./deploy.sh staging
390
+ only:
391
+ - main
392
+
393
+ deploy:production:
394
+ stage: deploy
395
+ environment:
396
+ name: production
397
+ url: https://example.com
398
+ script:
399
+ - ./deploy.sh production
400
+ when: manual
401
+ only:
402
+ - main
403
+ ```
404
+ }
405
+
406
+ PipelineRules {
407
+ ```yaml
408
+ deploy:production:
409
+ rules:
410
+ - if: $CI_COMMIT_BRANCH == "main"
411
+ when: manual
412
+ - if: $CI_COMMIT_TAG
413
+ when: on_success
414
+ - when: never
415
+ ```
416
+ }
417
+
418
+ IncludeTemplates {
419
+ ```yaml
420
+ include:
421
+ - template: Security/SAST.gitlab-ci.yml
422
+ - template: Security/Dependency-Scanning.gitlab-ci.yml
423
+ - local: .gitlab/ci/deploy.yml
424
+ - project: 'devops/ci-templates'
425
+ ref: main
426
+ file: '/templates/docker-build.yml'
427
+ ```
428
+ }
429
+
430
+ DynamicEnvironments {
431
+ ```yaml
432
+ deploy:review:
433
+ stage: deploy
434
+ environment:
435
+ name: review/$CI_COMMIT_REF_SLUG
436
+ url: https://$CI_COMMIT_REF_SLUG.review.example.com
437
+ on_stop: stop:review
438
+ script:
439
+ - ./deploy.sh review
440
+ only:
441
+ - merge_requests
442
+
443
+ stop:review:
444
+ stage: deploy
445
+ environment:
446
+ name: review/$CI_COMMIT_REF_SLUG
447
+ action: stop
448
+ script:
449
+ - ./teardown.sh review
450
+ when: manual
451
+ only:
452
+ - merge_requests
453
+ ```
454
+ }
455
+ }
456
+
457
+ RollbackMechanisms {
458
+ AutomatedRollbackTriggers {
459
+ ```yaml
460
+ # Conceptual rollback configuration
461
+ rollback:
462
+ triggers:
463
+ - metric: error_rate
464
+ threshold: 5%
465
+ window: 5m
466
+ - metric: latency_p99
467
+ threshold: 2000ms
468
+ window: 5m
469
+ - metric: health_check_failures
470
+ threshold: 3
471
+ window: 1m
472
+ action:
473
+ type: previous_version
474
+ notify:
475
+ - slack: #deployments
476
+ - pagerduty: on-call
477
+ ```
478
+ }
479
+
480
+ DatabaseMigrationRollback {
481
+ ForwardOnlyMigrations {
482
+ Description: "Preferred approach"
483
+ Rules {
484
+ Never use destructive operations (DROP, DELETE)
485
+ Add new columns as nullable
486
+ Use feature flags to switch behavior
487
+ Clean up old columns in later release
488
+ }
489
+ }
490
+
491
+ RollbackMigrations {
492
+ Every migration must have a corresponding rollback
493
+ Test rollbacks in staging before production
494
+ Keep rollback window defined (e.g., 24 hours)
495
+ }
496
+ }
497
+
498
+ ArtifactBasedRollback {
499
+ ```yaml
500
+ rollback:production:
501
+ stage: deploy
502
+ environment:
503
+ name: production
504
+ script:
505
+ - PREVIOUS_VERSION=$(get-previous-version.sh)
506
+ - ./deploy.sh production $PREVIOUS_VERSION
507
+ when: manual
508
+ only:
509
+ - main
510
+ ```
511
+ }
512
+ }
513
+
514
+ SecurityIntegration {
515
+ SASTDASTIntegration {
516
+ ```yaml
517
+ security:sast:
518
+ stage: analyze
519
+ image: security-scanner:latest
520
+ script:
521
+ - sast-scan --format sarif --output sast-results.sarif
522
+ artifacts:
523
+ reports:
524
+ sast: sast-results.sarif
525
+
526
+ security:dependency:
527
+ stage: analyze
528
+ script:
529
+ - npm audit --audit-level=high
530
+ - trivy fs --security-checks vuln .
531
+ ```
532
+ }
533
+
534
+ SecretScanning {
535
+ Never commit secrets to repository
536
+ Use environment secrets or vault integration
537
+ Scan for exposed secrets in pre-commit hooks
538
+ Rotate secrets immediately if exposed
539
+ }
540
+ }
541
+
542
+ BestPractices {
543
+ PipelineDesign {
544
+ Keep pipelines under 15 minutes for main branch
545
+ Use caching aggressively for dependencies
546
+ Run expensive tests in parallel
547
+ Fail fast with quick checks first
548
+ Use artifacts to avoid rebuilding
549
+ }
550
+
551
+ DeploymentSafety {
552
+ Always have a rollback plan
553
+ Deploy to staging before production
554
+ Use feature flags for risky changes
555
+ Monitor deployments in real-time
556
+ Document deployment procedures
557
+ }
558
+
559
+ QualityAssurance {
560
+ Enforce code coverage thresholds
561
+ Block deployments on security findings
562
+ Require peer approval for production
563
+ Maintain environment parity
564
+ Test rollback procedures regularly
565
+ }
566
+
567
+ Observability {
568
+ Log all deployment events
569
+ Track deployment frequency and lead time
570
+ Monitor change failure rate
571
+ Measure mean time to recovery
572
+ Alert on deployment failures
573
+ }
574
+ }
575
+ }
576
+
577
+ ## References
578
+
579
+ - [pipeline-template.md](templates/pipeline-template.md) - Complete pipeline template with all stages