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.
- package/README.md +140 -0
- package/dist/cli.cjs +63 -0
- package/dist/mcp-server.cjs +51 -0
- package/dist/plugin.cjs +4 -0
- package/dist/worker.cjs +224 -0
- package/opencode/agent/the-analyst/feature-prioritization.md +66 -0
- package/opencode/agent/the-analyst/market-research.md +77 -0
- package/opencode/agent/the-analyst/project-coordination.md +81 -0
- package/opencode/agent/the-analyst/requirements-analysis.md +77 -0
- package/opencode/agent/the-architect/compatibility-review.md +138 -0
- package/opencode/agent/the-architect/complexity-review.md +137 -0
- package/opencode/agent/the-architect/quality-review.md +67 -0
- package/opencode/agent/the-architect/security-review.md +127 -0
- package/opencode/agent/the-architect/system-architecture.md +119 -0
- package/opencode/agent/the-architect/system-documentation.md +83 -0
- package/opencode/agent/the-architect/technology-research.md +85 -0
- package/opencode/agent/the-chief.md +79 -0
- package/opencode/agent/the-designer/accessibility-implementation.md +101 -0
- package/opencode/agent/the-designer/design-foundation.md +74 -0
- package/opencode/agent/the-designer/interaction-architecture.md +75 -0
- package/opencode/agent/the-designer/user-research.md +70 -0
- package/opencode/agent/the-meta-agent.md +155 -0
- package/opencode/agent/the-platform-engineer/ci-cd-pipelines.md +109 -0
- package/opencode/agent/the-platform-engineer/containerization.md +106 -0
- package/opencode/agent/the-platform-engineer/data-architecture.md +81 -0
- package/opencode/agent/the-platform-engineer/dependency-review.md +144 -0
- package/opencode/agent/the-platform-engineer/deployment-automation.md +81 -0
- package/opencode/agent/the-platform-engineer/infrastructure-as-code.md +107 -0
- package/opencode/agent/the-platform-engineer/performance-tuning.md +82 -0
- package/opencode/agent/the-platform-engineer/pipeline-engineering.md +81 -0
- package/opencode/agent/the-platform-engineer/production-monitoring.md +105 -0
- package/opencode/agent/the-qa-engineer/exploratory-testing.md +66 -0
- package/opencode/agent/the-qa-engineer/performance-testing.md +81 -0
- package/opencode/agent/the-qa-engineer/quality-assurance.md +77 -0
- package/opencode/agent/the-qa-engineer/test-execution.md +66 -0
- package/opencode/agent/the-software-engineer/api-development.md +78 -0
- package/opencode/agent/the-software-engineer/component-development.md +79 -0
- package/opencode/agent/the-software-engineer/concurrency-review.md +141 -0
- package/opencode/agent/the-software-engineer/domain-modeling.md +66 -0
- package/opencode/agent/the-software-engineer/performance-optimization.md +113 -0
- package/opencode/command/analyze.md +149 -0
- package/opencode/command/constitution.md +178 -0
- package/opencode/command/debug.md +194 -0
- package/opencode/command/document.md +178 -0
- package/opencode/command/implement.md +225 -0
- package/opencode/command/refactor.md +207 -0
- package/opencode/command/review.md +229 -0
- package/opencode/command/simplify.md +267 -0
- package/opencode/command/specify.md +191 -0
- package/opencode/command/validate.md +224 -0
- package/opencode/skill/accessibility-design/SKILL.md +566 -0
- package/opencode/skill/accessibility-design/checklists/wcag-checklist.md +435 -0
- package/opencode/skill/agent-coordination/SKILL.md +224 -0
- package/opencode/skill/api-contract-design/SKILL.md +550 -0
- package/opencode/skill/api-contract-design/templates/graphql-schema-template.md +818 -0
- package/opencode/skill/api-contract-design/templates/rest-api-template.md +417 -0
- package/opencode/skill/architecture-design/SKILL.md +160 -0
- package/opencode/skill/architecture-design/examples/architecture-examples.md +170 -0
- package/opencode/skill/architecture-design/template.md +749 -0
- package/opencode/skill/architecture-design/validation.md +99 -0
- package/opencode/skill/architecture-selection/SKILL.md +522 -0
- package/opencode/skill/architecture-selection/examples/adrs/001-example-adr.md +71 -0
- package/opencode/skill/architecture-selection/examples/architecture-patterns.md +239 -0
- package/opencode/skill/bug-diagnosis/SKILL.md +235 -0
- package/opencode/skill/code-quality-review/SKILL.md +337 -0
- package/opencode/skill/code-quality-review/examples/anti-patterns.md +629 -0
- package/opencode/skill/code-quality-review/reference.md +322 -0
- package/opencode/skill/code-review/SKILL.md +363 -0
- package/opencode/skill/code-review/reference.md +450 -0
- package/opencode/skill/codebase-analysis/SKILL.md +139 -0
- package/opencode/skill/codebase-navigation/SKILL.md +227 -0
- package/opencode/skill/codebase-navigation/examples/exploration-patterns.md +263 -0
- package/opencode/skill/coding-conventions/SKILL.md +178 -0
- package/opencode/skill/coding-conventions/checklists/accessibility-checklist.md +176 -0
- package/opencode/skill/coding-conventions/checklists/performance-checklist.md +154 -0
- package/opencode/skill/coding-conventions/checklists/security-checklist.md +127 -0
- package/opencode/skill/constitution-validation/SKILL.md +315 -0
- package/opencode/skill/constitution-validation/examples/CONSTITUTION.md +202 -0
- package/opencode/skill/constitution-validation/reference/rule-patterns.md +328 -0
- package/opencode/skill/constitution-validation/template.md +115 -0
- package/opencode/skill/context-preservation/SKILL.md +445 -0
- package/opencode/skill/data-modeling/SKILL.md +385 -0
- package/opencode/skill/data-modeling/templates/schema-design-template.md +268 -0
- package/opencode/skill/deployment-pipeline-design/SKILL.md +579 -0
- package/opencode/skill/deployment-pipeline-design/templates/pipeline-template.md +633 -0
- package/opencode/skill/documentation-extraction/SKILL.md +259 -0
- package/opencode/skill/documentation-sync/SKILL.md +431 -0
- package/opencode/skill/domain-driven-design/SKILL.md +509 -0
- package/opencode/skill/domain-driven-design/examples/ddd-patterns.md +688 -0
- package/opencode/skill/domain-driven-design/reference.md +465 -0
- package/opencode/skill/drift-detection/SKILL.md +383 -0
- package/opencode/skill/drift-detection/reference.md +340 -0
- package/opencode/skill/error-recovery/SKILL.md +162 -0
- package/opencode/skill/error-recovery/examples/error-patterns.md +484 -0
- package/opencode/skill/feature-prioritization/SKILL.md +419 -0
- package/opencode/skill/feature-prioritization/examples/rice-template.md +139 -0
- package/opencode/skill/feature-prioritization/reference.md +256 -0
- package/opencode/skill/git-workflow/SKILL.md +453 -0
- package/opencode/skill/implementation-planning/SKILL.md +215 -0
- package/opencode/skill/implementation-planning/examples/phase-examples.md +217 -0
- package/opencode/skill/implementation-planning/template.md +220 -0
- package/opencode/skill/implementation-planning/validation.md +88 -0
- package/opencode/skill/implementation-verification/SKILL.md +272 -0
- package/opencode/skill/knowledge-capture/SKILL.md +265 -0
- package/opencode/skill/knowledge-capture/reference/knowledge-capture.md +402 -0
- package/opencode/skill/knowledge-capture/reference.md +444 -0
- package/opencode/skill/knowledge-capture/templates/domain-template.md +325 -0
- package/opencode/skill/knowledge-capture/templates/interface-template.md +255 -0
- package/opencode/skill/knowledge-capture/templates/pattern-template.md +144 -0
- package/opencode/skill/observability-design/SKILL.md +291 -0
- package/opencode/skill/observability-design/references/monitoring-patterns.md +461 -0
- package/opencode/skill/pattern-detection/SKILL.md +171 -0
- package/opencode/skill/pattern-detection/examples/common-patterns.md +359 -0
- package/opencode/skill/performance-analysis/SKILL.md +266 -0
- package/opencode/skill/performance-analysis/references/profiling-tools.md +499 -0
- package/opencode/skill/requirements-analysis/SKILL.md +139 -0
- package/opencode/skill/requirements-analysis/examples/good-prd.md +66 -0
- package/opencode/skill/requirements-analysis/template.md +177 -0
- package/opencode/skill/requirements-analysis/validation.md +69 -0
- package/opencode/skill/requirements-elicitation/SKILL.md +518 -0
- package/opencode/skill/requirements-elicitation/examples/interview-questions.md +226 -0
- package/opencode/skill/requirements-elicitation/examples/user-stories.md +414 -0
- package/opencode/skill/safe-refactoring/SKILL.md +312 -0
- package/opencode/skill/safe-refactoring/reference/code-smells.md +347 -0
- package/opencode/skill/security-assessment/SKILL.md +421 -0
- package/opencode/skill/security-assessment/checklists/security-review-checklist.md +285 -0
- package/opencode/skill/specification-management/SKILL.md +143 -0
- package/opencode/skill/specification-management/readme-template.md +32 -0
- package/opencode/skill/specification-management/reference.md +115 -0
- package/opencode/skill/specification-management/spec.py +229 -0
- package/opencode/skill/specification-validation/SKILL.md +397 -0
- package/opencode/skill/specification-validation/reference/3cs-framework.md +306 -0
- package/opencode/skill/specification-validation/reference/ambiguity-detection.md +132 -0
- package/opencode/skill/specification-validation/reference/constitution-validation.md +301 -0
- package/opencode/skill/specification-validation/reference/drift-detection.md +383 -0
- package/opencode/skill/task-delegation/SKILL.md +607 -0
- package/opencode/skill/task-delegation/examples/file-coordination.md +495 -0
- package/opencode/skill/task-delegation/examples/parallel-research.md +337 -0
- package/opencode/skill/task-delegation/examples/sequential-build.md +504 -0
- package/opencode/skill/task-delegation/reference.md +825 -0
- package/opencode/skill/tech-stack-detection/SKILL.md +89 -0
- package/opencode/skill/tech-stack-detection/references/framework-signatures.md +598 -0
- package/opencode/skill/technical-writing/SKILL.md +190 -0
- package/opencode/skill/technical-writing/templates/adr-template.md +205 -0
- package/opencode/skill/technical-writing/templates/system-doc-template.md +380 -0
- package/opencode/skill/test-design/SKILL.md +464 -0
- package/opencode/skill/test-design/examples/test-pyramid.md +724 -0
- package/opencode/skill/testing/SKILL.md +213 -0
- package/opencode/skill/testing/examples/test-pyramid.md +724 -0
- package/opencode/skill/user-insight-synthesis/SKILL.md +576 -0
- package/opencode/skill/user-insight-synthesis/templates/research-plan-template.md +217 -0
- package/opencode/skill/user-research/SKILL.md +508 -0
- package/opencode/skill/user-research/examples/interview-questions.md +265 -0
- package/opencode/skill/user-research/examples/personas.md +267 -0
- package/opencode/skill/vibe-security/SKILL.md +654 -0
- package/package.json +45 -0
|
@@ -0,0 +1,633 @@
|
|
|
1
|
+
# Template: CI/CD Pipeline
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Complete pipeline template covering build, test, security scanning, and multi-environment deployment. Use this as a starting point for new projects or when modernizing existing pipelines.
|
|
6
|
+
|
|
7
|
+
## GitHub Actions Template
|
|
8
|
+
|
|
9
|
+
```yaml
|
|
10
|
+
# .github/workflows/ci-cd.yml
|
|
11
|
+
# Complete CI/CD Pipeline Template
|
|
12
|
+
#
|
|
13
|
+
# Features:
|
|
14
|
+
# - Build and test with caching
|
|
15
|
+
# - Security scanning (SAST, dependencies)
|
|
16
|
+
# - Multi-environment deployment (staging, production)
|
|
17
|
+
# - Manual approval for production
|
|
18
|
+
# - Automated rollback support
|
|
19
|
+
|
|
20
|
+
name: CI/CD Pipeline
|
|
21
|
+
|
|
22
|
+
on:
|
|
23
|
+
push:
|
|
24
|
+
branches: [main, develop]
|
|
25
|
+
pull_request:
|
|
26
|
+
branches: [main]
|
|
27
|
+
workflow_dispatch:
|
|
28
|
+
inputs:
|
|
29
|
+
environment:
|
|
30
|
+
description: 'Deploy to environment'
|
|
31
|
+
required: true
|
|
32
|
+
type: choice
|
|
33
|
+
options:
|
|
34
|
+
- staging
|
|
35
|
+
- production
|
|
36
|
+
|
|
37
|
+
# Prevent concurrent deployments to same environment
|
|
38
|
+
concurrency:
|
|
39
|
+
group: deploy-${{ github.ref }}
|
|
40
|
+
cancel-in-progress: false
|
|
41
|
+
|
|
42
|
+
env:
|
|
43
|
+
NODE_VERSION: '20'
|
|
44
|
+
REGISTRY: ghcr.io
|
|
45
|
+
IMAGE_NAME: ${{ github.repository }}
|
|
46
|
+
|
|
47
|
+
jobs:
|
|
48
|
+
# ============================================
|
|
49
|
+
# BUILD STAGE
|
|
50
|
+
# ============================================
|
|
51
|
+
build:
|
|
52
|
+
name: Build
|
|
53
|
+
runs-on: ubuntu-latest
|
|
54
|
+
outputs:
|
|
55
|
+
version: ${{ steps.version.outputs.version }}
|
|
56
|
+
steps:
|
|
57
|
+
- name: Checkout
|
|
58
|
+
uses: actions/checkout@v4
|
|
59
|
+
|
|
60
|
+
- name: Setup Node.js
|
|
61
|
+
uses: actions/setup-node@v4
|
|
62
|
+
with:
|
|
63
|
+
node-version: ${{ env.NODE_VERSION }}
|
|
64
|
+
cache: 'npm'
|
|
65
|
+
|
|
66
|
+
- name: Install dependencies
|
|
67
|
+
run: npm ci
|
|
68
|
+
|
|
69
|
+
- name: Build
|
|
70
|
+
run: npm run build
|
|
71
|
+
|
|
72
|
+
- name: Generate version
|
|
73
|
+
id: version
|
|
74
|
+
run: echo "version=${{ github.sha }}-$(date +%Y%m%d%H%M%S)" >> $GITHUB_OUTPUT
|
|
75
|
+
|
|
76
|
+
- name: Upload build artifact
|
|
77
|
+
uses: actions/upload-artifact@v4
|
|
78
|
+
with:
|
|
79
|
+
name: build-${{ github.sha }}
|
|
80
|
+
path: dist/
|
|
81
|
+
retention-days: 7
|
|
82
|
+
|
|
83
|
+
# ============================================
|
|
84
|
+
# TEST STAGE
|
|
85
|
+
# ============================================
|
|
86
|
+
test-unit:
|
|
87
|
+
name: Unit Tests
|
|
88
|
+
needs: build
|
|
89
|
+
runs-on: ubuntu-latest
|
|
90
|
+
steps:
|
|
91
|
+
- name: Checkout
|
|
92
|
+
uses: actions/checkout@v4
|
|
93
|
+
|
|
94
|
+
- name: Setup Node.js
|
|
95
|
+
uses: actions/setup-node@v4
|
|
96
|
+
with:
|
|
97
|
+
node-version: ${{ env.NODE_VERSION }}
|
|
98
|
+
cache: 'npm'
|
|
99
|
+
|
|
100
|
+
- name: Install dependencies
|
|
101
|
+
run: npm ci
|
|
102
|
+
|
|
103
|
+
- name: Run unit tests
|
|
104
|
+
run: npm run test:unit -- --coverage
|
|
105
|
+
|
|
106
|
+
- name: Upload coverage
|
|
107
|
+
uses: actions/upload-artifact@v4
|
|
108
|
+
with:
|
|
109
|
+
name: coverage-unit
|
|
110
|
+
path: coverage/
|
|
111
|
+
|
|
112
|
+
test-integration:
|
|
113
|
+
name: Integration Tests
|
|
114
|
+
needs: build
|
|
115
|
+
runs-on: ubuntu-latest
|
|
116
|
+
services:
|
|
117
|
+
postgres:
|
|
118
|
+
image: postgres:15
|
|
119
|
+
env:
|
|
120
|
+
POSTGRES_USER: test
|
|
121
|
+
POSTGRES_PASSWORD: test
|
|
122
|
+
POSTGRES_DB: test
|
|
123
|
+
ports:
|
|
124
|
+
- 5432:5432
|
|
125
|
+
options: >-
|
|
126
|
+
--health-cmd pg_isready
|
|
127
|
+
--health-interval 10s
|
|
128
|
+
--health-timeout 5s
|
|
129
|
+
--health-retries 5
|
|
130
|
+
steps:
|
|
131
|
+
- name: Checkout
|
|
132
|
+
uses: actions/checkout@v4
|
|
133
|
+
|
|
134
|
+
- name: Setup Node.js
|
|
135
|
+
uses: actions/setup-node@v4
|
|
136
|
+
with:
|
|
137
|
+
node-version: ${{ env.NODE_VERSION }}
|
|
138
|
+
cache: 'npm'
|
|
139
|
+
|
|
140
|
+
- name: Install dependencies
|
|
141
|
+
run: npm ci
|
|
142
|
+
|
|
143
|
+
- name: Run integration tests
|
|
144
|
+
run: npm run test:integration
|
|
145
|
+
env:
|
|
146
|
+
DATABASE_URL: postgresql://test:test@localhost:5432/test
|
|
147
|
+
|
|
148
|
+
test-e2e:
|
|
149
|
+
name: E2E Tests
|
|
150
|
+
needs: build
|
|
151
|
+
runs-on: ubuntu-latest
|
|
152
|
+
steps:
|
|
153
|
+
- name: Checkout
|
|
154
|
+
uses: actions/checkout@v4
|
|
155
|
+
|
|
156
|
+
- name: Setup Node.js
|
|
157
|
+
uses: actions/setup-node@v4
|
|
158
|
+
with:
|
|
159
|
+
node-version: ${{ env.NODE_VERSION }}
|
|
160
|
+
cache: 'npm'
|
|
161
|
+
|
|
162
|
+
- name: Install dependencies
|
|
163
|
+
run: npm ci
|
|
164
|
+
|
|
165
|
+
- name: Download build
|
|
166
|
+
uses: actions/download-artifact@v4
|
|
167
|
+
with:
|
|
168
|
+
name: build-${{ github.sha }}
|
|
169
|
+
path: dist/
|
|
170
|
+
|
|
171
|
+
- name: Run E2E tests
|
|
172
|
+
run: npm run test:e2e
|
|
173
|
+
|
|
174
|
+
# ============================================
|
|
175
|
+
# ANALYZE STAGE
|
|
176
|
+
# ============================================
|
|
177
|
+
lint:
|
|
178
|
+
name: Lint
|
|
179
|
+
needs: build
|
|
180
|
+
runs-on: ubuntu-latest
|
|
181
|
+
steps:
|
|
182
|
+
- name: Checkout
|
|
183
|
+
uses: actions/checkout@v4
|
|
184
|
+
|
|
185
|
+
- name: Setup Node.js
|
|
186
|
+
uses: actions/setup-node@v4
|
|
187
|
+
with:
|
|
188
|
+
node-version: ${{ env.NODE_VERSION }}
|
|
189
|
+
cache: 'npm'
|
|
190
|
+
|
|
191
|
+
- name: Install dependencies
|
|
192
|
+
run: npm ci
|
|
193
|
+
|
|
194
|
+
- name: Run linter
|
|
195
|
+
run: npm run lint
|
|
196
|
+
|
|
197
|
+
security-sast:
|
|
198
|
+
name: SAST Scan
|
|
199
|
+
needs: build
|
|
200
|
+
runs-on: ubuntu-latest
|
|
201
|
+
permissions:
|
|
202
|
+
security-events: write
|
|
203
|
+
steps:
|
|
204
|
+
- name: Checkout
|
|
205
|
+
uses: actions/checkout@v4
|
|
206
|
+
|
|
207
|
+
- name: Run CodeQL
|
|
208
|
+
uses: github/codeql-action/init@v3
|
|
209
|
+
with:
|
|
210
|
+
languages: javascript
|
|
211
|
+
|
|
212
|
+
- name: Autobuild
|
|
213
|
+
uses: github/codeql-action/autobuild@v3
|
|
214
|
+
|
|
215
|
+
- name: Perform CodeQL Analysis
|
|
216
|
+
uses: github/codeql-action/analyze@v3
|
|
217
|
+
|
|
218
|
+
security-dependencies:
|
|
219
|
+
name: Dependency Scan
|
|
220
|
+
needs: build
|
|
221
|
+
runs-on: ubuntu-latest
|
|
222
|
+
steps:
|
|
223
|
+
- name: Checkout
|
|
224
|
+
uses: actions/checkout@v4
|
|
225
|
+
|
|
226
|
+
- name: Setup Node.js
|
|
227
|
+
uses: actions/setup-node@v4
|
|
228
|
+
with:
|
|
229
|
+
node-version: ${{ env.NODE_VERSION }}
|
|
230
|
+
cache: 'npm'
|
|
231
|
+
|
|
232
|
+
- name: Install dependencies
|
|
233
|
+
run: npm ci
|
|
234
|
+
|
|
235
|
+
- name: Audit dependencies
|
|
236
|
+
run: npm audit --audit-level=high
|
|
237
|
+
|
|
238
|
+
# ============================================
|
|
239
|
+
# PACKAGE STAGE
|
|
240
|
+
# ============================================
|
|
241
|
+
package:
|
|
242
|
+
name: Package
|
|
243
|
+
needs: [test-unit, test-integration, lint, security-sast, security-dependencies]
|
|
244
|
+
runs-on: ubuntu-latest
|
|
245
|
+
permissions:
|
|
246
|
+
contents: read
|
|
247
|
+
packages: write
|
|
248
|
+
outputs:
|
|
249
|
+
image-tag: ${{ steps.meta.outputs.tags }}
|
|
250
|
+
steps:
|
|
251
|
+
- name: Checkout
|
|
252
|
+
uses: actions/checkout@v4
|
|
253
|
+
|
|
254
|
+
- name: Download build
|
|
255
|
+
uses: actions/download-artifact@v4
|
|
256
|
+
with:
|
|
257
|
+
name: build-${{ github.sha }}
|
|
258
|
+
path: dist/
|
|
259
|
+
|
|
260
|
+
- name: Setup Docker Buildx
|
|
261
|
+
uses: docker/setup-buildx-action@v3
|
|
262
|
+
|
|
263
|
+
- name: Login to Registry
|
|
264
|
+
uses: docker/login-action@v3
|
|
265
|
+
with:
|
|
266
|
+
registry: ${{ env.REGISTRY }}
|
|
267
|
+
username: ${{ github.actor }}
|
|
268
|
+
password: ${{ secrets.GITHUB_TOKEN }}
|
|
269
|
+
|
|
270
|
+
- name: Extract metadata
|
|
271
|
+
id: meta
|
|
272
|
+
uses: docker/metadata-action@v5
|
|
273
|
+
with:
|
|
274
|
+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
275
|
+
tags: |
|
|
276
|
+
type=sha,prefix=
|
|
277
|
+
type=ref,event=branch
|
|
278
|
+
type=semver,pattern={{version}}
|
|
279
|
+
|
|
280
|
+
- name: Build and push
|
|
281
|
+
uses: docker/build-push-action@v5
|
|
282
|
+
with:
|
|
283
|
+
context: .
|
|
284
|
+
push: true
|
|
285
|
+
tags: ${{ steps.meta.outputs.tags }}
|
|
286
|
+
labels: ${{ steps.meta.outputs.labels }}
|
|
287
|
+
cache-from: type=gha
|
|
288
|
+
cache-to: type=gha,mode=max
|
|
289
|
+
|
|
290
|
+
# ============================================
|
|
291
|
+
# DEPLOY STAGING
|
|
292
|
+
# ============================================
|
|
293
|
+
deploy-staging:
|
|
294
|
+
name: Deploy Staging
|
|
295
|
+
needs: package
|
|
296
|
+
if: github.ref == 'refs/heads/main'
|
|
297
|
+
runs-on: ubuntu-latest
|
|
298
|
+
environment:
|
|
299
|
+
name: staging
|
|
300
|
+
url: https://staging.example.com
|
|
301
|
+
steps:
|
|
302
|
+
- name: Checkout
|
|
303
|
+
uses: actions/checkout@v4
|
|
304
|
+
|
|
305
|
+
- name: Deploy to staging
|
|
306
|
+
run: |
|
|
307
|
+
echo "Deploying to staging..."
|
|
308
|
+
# Replace with actual deployment command
|
|
309
|
+
# kubectl set image deployment/app app=${{ needs.package.outputs.image-tag }}
|
|
310
|
+
# OR
|
|
311
|
+
# aws ecs update-service --cluster staging --service app --force-new-deployment
|
|
312
|
+
|
|
313
|
+
- name: Wait for deployment
|
|
314
|
+
run: |
|
|
315
|
+
echo "Waiting for deployment to complete..."
|
|
316
|
+
# kubectl rollout status deployment/app --timeout=300s
|
|
317
|
+
sleep 30
|
|
318
|
+
|
|
319
|
+
- name: Run smoke tests
|
|
320
|
+
run: |
|
|
321
|
+
echo "Running smoke tests..."
|
|
322
|
+
# curl -f https://staging.example.com/health || exit 1
|
|
323
|
+
|
|
324
|
+
# ============================================
|
|
325
|
+
# DEPLOY PRODUCTION
|
|
326
|
+
# ============================================
|
|
327
|
+
deploy-production:
|
|
328
|
+
name: Deploy Production
|
|
329
|
+
needs: deploy-staging
|
|
330
|
+
if: github.ref == 'refs/heads/main'
|
|
331
|
+
runs-on: ubuntu-latest
|
|
332
|
+
environment:
|
|
333
|
+
name: production
|
|
334
|
+
url: https://example.com
|
|
335
|
+
steps:
|
|
336
|
+
- name: Checkout
|
|
337
|
+
uses: actions/checkout@v4
|
|
338
|
+
|
|
339
|
+
- name: Deploy to production
|
|
340
|
+
run: |
|
|
341
|
+
echo "Deploying to production..."
|
|
342
|
+
# Replace with actual deployment command
|
|
343
|
+
|
|
344
|
+
- name: Wait for deployment
|
|
345
|
+
run: |
|
|
346
|
+
echo "Waiting for deployment to complete..."
|
|
347
|
+
sleep 30
|
|
348
|
+
|
|
349
|
+
- name: Run smoke tests
|
|
350
|
+
run: |
|
|
351
|
+
echo "Running smoke tests..."
|
|
352
|
+
# curl -f https://example.com/health || exit 1
|
|
353
|
+
|
|
354
|
+
- name: Notify success
|
|
355
|
+
if: success()
|
|
356
|
+
run: |
|
|
357
|
+
echo "Deployment successful!"
|
|
358
|
+
# Send Slack notification, etc.
|
|
359
|
+
|
|
360
|
+
# ============================================
|
|
361
|
+
# ROLLBACK (Manual Trigger)
|
|
362
|
+
# ============================================
|
|
363
|
+
rollback:
|
|
364
|
+
name: Rollback Production
|
|
365
|
+
if: github.event_name == 'workflow_dispatch' && failure()
|
|
366
|
+
needs: deploy-production
|
|
367
|
+
runs-on: ubuntu-latest
|
|
368
|
+
environment:
|
|
369
|
+
name: production
|
|
370
|
+
steps:
|
|
371
|
+
- name: Rollback deployment
|
|
372
|
+
run: |
|
|
373
|
+
echo "Rolling back production..."
|
|
374
|
+
# kubectl rollout undo deployment/app
|
|
375
|
+
# OR
|
|
376
|
+
# aws ecs update-service --cluster production --service app --task-definition previous-version
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
## GitLab CI Template
|
|
380
|
+
|
|
381
|
+
```yaml
|
|
382
|
+
# .gitlab-ci.yml
|
|
383
|
+
# Complete CI/CD Pipeline Template
|
|
384
|
+
#
|
|
385
|
+
# Features:
|
|
386
|
+
# - Build and test with caching
|
|
387
|
+
# - Security scanning (SAST, dependencies)
|
|
388
|
+
# - Multi-environment deployment (staging, production)
|
|
389
|
+
# - Manual approval for production
|
|
390
|
+
# - Automated rollback support
|
|
391
|
+
|
|
392
|
+
stages:
|
|
393
|
+
- build
|
|
394
|
+
- test
|
|
395
|
+
- analyze
|
|
396
|
+
- package
|
|
397
|
+
- deploy
|
|
398
|
+
- verify
|
|
399
|
+
|
|
400
|
+
variables:
|
|
401
|
+
NODE_VERSION: "20"
|
|
402
|
+
DOCKER_TLS_CERTDIR: "/certs"
|
|
403
|
+
|
|
404
|
+
default:
|
|
405
|
+
image: node:${NODE_VERSION}
|
|
406
|
+
cache:
|
|
407
|
+
key: ${CI_COMMIT_REF_SLUG}
|
|
408
|
+
paths:
|
|
409
|
+
- node_modules/
|
|
410
|
+
- .npm/
|
|
411
|
+
|
|
412
|
+
# ============================================
|
|
413
|
+
# BUILD STAGE
|
|
414
|
+
# ============================================
|
|
415
|
+
build:
|
|
416
|
+
stage: build
|
|
417
|
+
script:
|
|
418
|
+
- npm ci --cache .npm --prefer-offline
|
|
419
|
+
- npm run build
|
|
420
|
+
artifacts:
|
|
421
|
+
paths:
|
|
422
|
+
- dist/
|
|
423
|
+
expire_in: 1 day
|
|
424
|
+
|
|
425
|
+
# ============================================
|
|
426
|
+
# TEST STAGE
|
|
427
|
+
# ============================================
|
|
428
|
+
test:unit:
|
|
429
|
+
stage: test
|
|
430
|
+
needs: [build]
|
|
431
|
+
script:
|
|
432
|
+
- npm ci --cache .npm --prefer-offline
|
|
433
|
+
- npm run test:unit -- --coverage
|
|
434
|
+
coverage: '/All files[^|]*\|[^|]*\s+([\d\.]+)/'
|
|
435
|
+
artifacts:
|
|
436
|
+
reports:
|
|
437
|
+
coverage_report:
|
|
438
|
+
coverage_format: cobertura
|
|
439
|
+
path: coverage/cobertura-coverage.xml
|
|
440
|
+
paths:
|
|
441
|
+
- coverage/
|
|
442
|
+
|
|
443
|
+
test:integration:
|
|
444
|
+
stage: test
|
|
445
|
+
needs: [build]
|
|
446
|
+
services:
|
|
447
|
+
- name: postgres:15
|
|
448
|
+
alias: database
|
|
449
|
+
variables:
|
|
450
|
+
POSTGRES_USER: test
|
|
451
|
+
POSTGRES_PASSWORD: test
|
|
452
|
+
POSTGRES_DB: test
|
|
453
|
+
DATABASE_URL: postgresql://test:test@database:5432/test
|
|
454
|
+
script:
|
|
455
|
+
- npm ci --cache .npm --prefer-offline
|
|
456
|
+
- npm run test:integration
|
|
457
|
+
|
|
458
|
+
test:e2e:
|
|
459
|
+
stage: test
|
|
460
|
+
needs: [build]
|
|
461
|
+
script:
|
|
462
|
+
- npm ci --cache .npm --prefer-offline
|
|
463
|
+
- npm run test:e2e
|
|
464
|
+
|
|
465
|
+
# ============================================
|
|
466
|
+
# ANALYZE STAGE
|
|
467
|
+
# ============================================
|
|
468
|
+
lint:
|
|
469
|
+
stage: analyze
|
|
470
|
+
needs: [build]
|
|
471
|
+
script:
|
|
472
|
+
- npm ci --cache .npm --prefer-offline
|
|
473
|
+
- npm run lint
|
|
474
|
+
allow_failure: false
|
|
475
|
+
|
|
476
|
+
# Include GitLab security templates
|
|
477
|
+
include:
|
|
478
|
+
- template: Security/SAST.gitlab-ci.yml
|
|
479
|
+
- template: Security/Dependency-Scanning.gitlab-ci.yml
|
|
480
|
+
- template: Security/Secret-Detection.gitlab-ci.yml
|
|
481
|
+
|
|
482
|
+
sast:
|
|
483
|
+
stage: analyze
|
|
484
|
+
needs: []
|
|
485
|
+
|
|
486
|
+
dependency_scanning:
|
|
487
|
+
stage: analyze
|
|
488
|
+
needs: []
|
|
489
|
+
|
|
490
|
+
secret_detection:
|
|
491
|
+
stage: analyze
|
|
492
|
+
needs: []
|
|
493
|
+
|
|
494
|
+
# ============================================
|
|
495
|
+
# PACKAGE STAGE
|
|
496
|
+
# ============================================
|
|
497
|
+
package:docker:
|
|
498
|
+
stage: package
|
|
499
|
+
needs:
|
|
500
|
+
- job: build
|
|
501
|
+
artifacts: true
|
|
502
|
+
- job: test:unit
|
|
503
|
+
- job: test:integration
|
|
504
|
+
- job: lint
|
|
505
|
+
image: docker:24
|
|
506
|
+
services:
|
|
507
|
+
- docker:24-dind
|
|
508
|
+
variables:
|
|
509
|
+
DOCKER_HOST: tcp://docker:2376
|
|
510
|
+
script:
|
|
511
|
+
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
|
512
|
+
- docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA -t $CI_REGISTRY_IMAGE:latest .
|
|
513
|
+
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
|
|
514
|
+
- docker push $CI_REGISTRY_IMAGE:latest
|
|
515
|
+
only:
|
|
516
|
+
- main
|
|
517
|
+
- tags
|
|
518
|
+
|
|
519
|
+
# ============================================
|
|
520
|
+
# DEPLOY STAGING
|
|
521
|
+
# ============================================
|
|
522
|
+
deploy:staging:
|
|
523
|
+
stage: deploy
|
|
524
|
+
needs: [package:docker]
|
|
525
|
+
environment:
|
|
526
|
+
name: staging
|
|
527
|
+
url: https://staging.example.com
|
|
528
|
+
script:
|
|
529
|
+
- echo "Deploying to staging..."
|
|
530
|
+
# Replace with actual deployment commands
|
|
531
|
+
# - kubectl set image deployment/app app=$CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
|
|
532
|
+
only:
|
|
533
|
+
- main
|
|
534
|
+
|
|
535
|
+
verify:staging:
|
|
536
|
+
stage: verify
|
|
537
|
+
needs: [deploy:staging]
|
|
538
|
+
environment:
|
|
539
|
+
name: staging
|
|
540
|
+
url: https://staging.example.com
|
|
541
|
+
script:
|
|
542
|
+
- echo "Running smoke tests on staging..."
|
|
543
|
+
# - curl -f https://staging.example.com/health
|
|
544
|
+
only:
|
|
545
|
+
- main
|
|
546
|
+
|
|
547
|
+
# ============================================
|
|
548
|
+
# DEPLOY PRODUCTION
|
|
549
|
+
# ============================================
|
|
550
|
+
deploy:production:
|
|
551
|
+
stage: deploy
|
|
552
|
+
needs: [verify:staging]
|
|
553
|
+
environment:
|
|
554
|
+
name: production
|
|
555
|
+
url: https://example.com
|
|
556
|
+
script:
|
|
557
|
+
- echo "Deploying to production..."
|
|
558
|
+
# Replace with actual deployment commands
|
|
559
|
+
when: manual
|
|
560
|
+
only:
|
|
561
|
+
- main
|
|
562
|
+
|
|
563
|
+
verify:production:
|
|
564
|
+
stage: verify
|
|
565
|
+
needs: [deploy:production]
|
|
566
|
+
environment:
|
|
567
|
+
name: production
|
|
568
|
+
url: https://example.com
|
|
569
|
+
script:
|
|
570
|
+
- echo "Running smoke tests on production..."
|
|
571
|
+
# - curl -f https://example.com/health
|
|
572
|
+
only:
|
|
573
|
+
- main
|
|
574
|
+
|
|
575
|
+
# ============================================
|
|
576
|
+
# ROLLBACK (Manual)
|
|
577
|
+
# ============================================
|
|
578
|
+
rollback:production:
|
|
579
|
+
stage: deploy
|
|
580
|
+
environment:
|
|
581
|
+
name: production
|
|
582
|
+
url: https://example.com
|
|
583
|
+
script:
|
|
584
|
+
- echo "Rolling back production..."
|
|
585
|
+
# - kubectl rollout undo deployment/app
|
|
586
|
+
when: manual
|
|
587
|
+
only:
|
|
588
|
+
- main
|
|
589
|
+
```
|
|
590
|
+
|
|
591
|
+
## Usage Instructions
|
|
592
|
+
|
|
593
|
+
1. Copy the appropriate template (GitHub Actions or GitLab CI)
|
|
594
|
+
2. Replace placeholder deployment commands with actual commands for your platform
|
|
595
|
+
3. Configure environment protection rules in your repository settings
|
|
596
|
+
4. Set up required secrets:
|
|
597
|
+
- Container registry credentials
|
|
598
|
+
- Deployment credentials
|
|
599
|
+
- Notification service tokens (Slack, etc.)
|
|
600
|
+
5. Customize test commands to match your project setup
|
|
601
|
+
6. Adjust Docker build context and configuration as needed
|
|
602
|
+
7. Configure environment URLs
|
|
603
|
+
|
|
604
|
+
## Customization Points
|
|
605
|
+
|
|
606
|
+
| Section | What to Customize |
|
|
607
|
+
|---------|-------------------|
|
|
608
|
+
| `NODE_VERSION` | Match your project's Node.js version |
|
|
609
|
+
| Database service | Replace with your database (MySQL, MongoDB, etc.) |
|
|
610
|
+
| `npm run` commands | Match your package.json scripts |
|
|
611
|
+
| Registry | Use your container registry (ECR, GCR, Docker Hub) |
|
|
612
|
+
| Deployment commands | Replace with kubectl, aws, gcloud, etc. |
|
|
613
|
+
| Environment URLs | Set actual staging/production URLs |
|
|
614
|
+
| Smoke tests | Add actual health check endpoints |
|
|
615
|
+
|
|
616
|
+
## Environment Variables Required
|
|
617
|
+
|
|
618
|
+
### GitHub Actions
|
|
619
|
+
- `GITHUB_TOKEN` - Automatically provided
|
|
620
|
+
- Deployment secrets configured per environment
|
|
621
|
+
|
|
622
|
+
### GitLab CI
|
|
623
|
+
- `CI_REGISTRY_USER` - Automatically provided
|
|
624
|
+
- `CI_REGISTRY_PASSWORD` - Automatically provided
|
|
625
|
+
- Deployment variables in CI/CD settings
|
|
626
|
+
|
|
627
|
+
## Examples
|
|
628
|
+
|
|
629
|
+
See CI/CD implementations in production projects for real-world examples with:
|
|
630
|
+
- Kubernetes deployments
|
|
631
|
+
- AWS ECS/Fargate
|
|
632
|
+
- Vercel/Netlify
|
|
633
|
+
- Cloud Run/App Engine
|