agentic-team-templates 0.3.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 (103) hide show
  1. package/README.md +280 -0
  2. package/bin/cli.js +5 -0
  3. package/package.json +47 -0
  4. package/src/index.js +521 -0
  5. package/templates/_shared/code-quality.md +162 -0
  6. package/templates/_shared/communication.md +114 -0
  7. package/templates/_shared/core-principles.md +62 -0
  8. package/templates/_shared/git-workflow.md +165 -0
  9. package/templates/_shared/security-fundamentals.md +173 -0
  10. package/templates/blockchain/.cursorrules/defi-patterns.md +520 -0
  11. package/templates/blockchain/.cursorrules/gas-optimization.md +339 -0
  12. package/templates/blockchain/.cursorrules/overview.md +130 -0
  13. package/templates/blockchain/.cursorrules/security.md +318 -0
  14. package/templates/blockchain/.cursorrules/smart-contracts.md +364 -0
  15. package/templates/blockchain/.cursorrules/testing.md +415 -0
  16. package/templates/blockchain/.cursorrules/web3-integration.md +538 -0
  17. package/templates/blockchain/CLAUDE.md +389 -0
  18. package/templates/cli-tools/.cursorrules/architecture.md +412 -0
  19. package/templates/cli-tools/.cursorrules/arguments.md +406 -0
  20. package/templates/cli-tools/.cursorrules/distribution.md +546 -0
  21. package/templates/cli-tools/.cursorrules/error-handling.md +455 -0
  22. package/templates/cli-tools/.cursorrules/overview.md +136 -0
  23. package/templates/cli-tools/.cursorrules/testing.md +537 -0
  24. package/templates/cli-tools/.cursorrules/user-experience.md +545 -0
  25. package/templates/cli-tools/CLAUDE.md +356 -0
  26. package/templates/data-engineering/.cursorrules/data-modeling.md +367 -0
  27. package/templates/data-engineering/.cursorrules/data-quality.md +455 -0
  28. package/templates/data-engineering/.cursorrules/overview.md +85 -0
  29. package/templates/data-engineering/.cursorrules/performance.md +339 -0
  30. package/templates/data-engineering/.cursorrules/pipeline-design.md +280 -0
  31. package/templates/data-engineering/.cursorrules/security.md +460 -0
  32. package/templates/data-engineering/.cursorrules/testing.md +452 -0
  33. package/templates/data-engineering/CLAUDE.md +974 -0
  34. package/templates/devops-sre/.cursorrules/capacity-planning.md +653 -0
  35. package/templates/devops-sre/.cursorrules/change-management.md +584 -0
  36. package/templates/devops-sre/.cursorrules/chaos-engineering.md +651 -0
  37. package/templates/devops-sre/.cursorrules/disaster-recovery.md +641 -0
  38. package/templates/devops-sre/.cursorrules/incident-management.md +565 -0
  39. package/templates/devops-sre/.cursorrules/observability.md +714 -0
  40. package/templates/devops-sre/.cursorrules/overview.md +230 -0
  41. package/templates/devops-sre/.cursorrules/postmortems.md +588 -0
  42. package/templates/devops-sre/.cursorrules/runbooks.md +760 -0
  43. package/templates/devops-sre/.cursorrules/slo-sli.md +617 -0
  44. package/templates/devops-sre/.cursorrules/toil-reduction.md +567 -0
  45. package/templates/devops-sre/CLAUDE.md +1007 -0
  46. package/templates/documentation/.cursorrules/adr.md +277 -0
  47. package/templates/documentation/.cursorrules/api-documentation.md +411 -0
  48. package/templates/documentation/.cursorrules/code-comments.md +253 -0
  49. package/templates/documentation/.cursorrules/maintenance.md +260 -0
  50. package/templates/documentation/.cursorrules/overview.md +82 -0
  51. package/templates/documentation/.cursorrules/readme-standards.md +306 -0
  52. package/templates/documentation/CLAUDE.md +120 -0
  53. package/templates/fullstack/.cursorrules/api-contracts.md +331 -0
  54. package/templates/fullstack/.cursorrules/architecture.md +298 -0
  55. package/templates/fullstack/.cursorrules/overview.md +109 -0
  56. package/templates/fullstack/.cursorrules/shared-types.md +348 -0
  57. package/templates/fullstack/.cursorrules/testing.md +386 -0
  58. package/templates/fullstack/CLAUDE.md +349 -0
  59. package/templates/ml-ai/.cursorrules/data-engineering.md +483 -0
  60. package/templates/ml-ai/.cursorrules/deployment.md +601 -0
  61. package/templates/ml-ai/.cursorrules/model-development.md +538 -0
  62. package/templates/ml-ai/.cursorrules/monitoring.md +658 -0
  63. package/templates/ml-ai/.cursorrules/overview.md +131 -0
  64. package/templates/ml-ai/.cursorrules/security.md +637 -0
  65. package/templates/ml-ai/.cursorrules/testing.md +678 -0
  66. package/templates/ml-ai/CLAUDE.md +1136 -0
  67. package/templates/mobile/.cursorrules/navigation.md +246 -0
  68. package/templates/mobile/.cursorrules/offline-first.md +302 -0
  69. package/templates/mobile/.cursorrules/overview.md +71 -0
  70. package/templates/mobile/.cursorrules/performance.md +345 -0
  71. package/templates/mobile/.cursorrules/testing.md +339 -0
  72. package/templates/mobile/CLAUDE.md +233 -0
  73. package/templates/platform-engineering/.cursorrules/ci-cd.md +778 -0
  74. package/templates/platform-engineering/.cursorrules/developer-experience.md +632 -0
  75. package/templates/platform-engineering/.cursorrules/infrastructure-as-code.md +600 -0
  76. package/templates/platform-engineering/.cursorrules/kubernetes.md +710 -0
  77. package/templates/platform-engineering/.cursorrules/observability.md +747 -0
  78. package/templates/platform-engineering/.cursorrules/overview.md +215 -0
  79. package/templates/platform-engineering/.cursorrules/security.md +855 -0
  80. package/templates/platform-engineering/.cursorrules/testing.md +878 -0
  81. package/templates/platform-engineering/CLAUDE.md +850 -0
  82. package/templates/utility-agent/.cursorrules/action-control.md +284 -0
  83. package/templates/utility-agent/.cursorrules/context-management.md +186 -0
  84. package/templates/utility-agent/.cursorrules/hallucination-prevention.md +253 -0
  85. package/templates/utility-agent/.cursorrules/overview.md +78 -0
  86. package/templates/utility-agent/.cursorrules/token-optimization.md +369 -0
  87. package/templates/utility-agent/CLAUDE.md +513 -0
  88. package/templates/web-backend/.cursorrules/api-design.md +255 -0
  89. package/templates/web-backend/.cursorrules/authentication.md +309 -0
  90. package/templates/web-backend/.cursorrules/database-patterns.md +298 -0
  91. package/templates/web-backend/.cursorrules/error-handling.md +366 -0
  92. package/templates/web-backend/.cursorrules/overview.md +69 -0
  93. package/templates/web-backend/.cursorrules/security.md +358 -0
  94. package/templates/web-backend/.cursorrules/testing.md +395 -0
  95. package/templates/web-backend/CLAUDE.md +366 -0
  96. package/templates/web-frontend/.cursorrules/accessibility.md +296 -0
  97. package/templates/web-frontend/.cursorrules/component-patterns.md +204 -0
  98. package/templates/web-frontend/.cursorrules/overview.md +72 -0
  99. package/templates/web-frontend/.cursorrules/performance.md +325 -0
  100. package/templates/web-frontend/.cursorrules/state-management.md +227 -0
  101. package/templates/web-frontend/.cursorrules/styling.md +271 -0
  102. package/templates/web-frontend/.cursorrules/testing.md +311 -0
  103. package/templates/web-frontend/CLAUDE.md +399 -0
@@ -0,0 +1,778 @@
1
+ # CI/CD & GitOps
2
+
3
+ Guidelines for building reliable, secure, and efficient delivery pipelines.
4
+
5
+ ## Core Principles
6
+
7
+ 1. **Everything as Code** - Pipelines, configuration, and infrastructure
8
+ 2. **Trunk-Based Development** - Short-lived branches, frequent integration
9
+ 3. **Shift Left** - Test, scan, and validate early in the pipeline
10
+ 4. **Immutable Artifacts** - Build once, deploy everywhere
11
+ 5. **GitOps** - Git as the single source of truth for deployments
12
+
13
+ ## Pipeline Architecture
14
+
15
+ ### Pipeline Stages
16
+
17
+ ```
18
+ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐
19
+ │ Validate │ → │ Test │ → │ Build │ → │ Scan │ → │ Deploy │
20
+ ├─────────────┤ ├─────────────┤ ├─────────────┤ ├─────────────┤ ├─────────────┤
21
+ │ Lint │ │ Unit │ │ Container │ │ SAST │ │ Staging │
22
+ │ Format │ │ Integration │ │ Helm │ │ DAST │ │ Production │
23
+ │ Validate │ │ Contract │ │ Docs │ │ Dependency │ │ │
24
+ └─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘
25
+ ```
26
+
27
+ ### GitHub Actions - Complete Pipeline
28
+
29
+ ```yaml
30
+ name: CI/CD Pipeline
31
+
32
+ on:
33
+ push:
34
+ branches: [main, develop]
35
+ pull_request:
36
+ branches: [main]
37
+ release:
38
+ types: [published]
39
+
40
+ env:
41
+ REGISTRY: ghcr.io
42
+ IMAGE_NAME: ${{ github.repository }}
43
+
44
+ permissions:
45
+ contents: read
46
+ packages: write
47
+ id-token: write # For OIDC
48
+ security-events: write
49
+
50
+ jobs:
51
+ # ============================================
52
+ # Stage 1: Validate
53
+ # ============================================
54
+ validate:
55
+ name: Validate
56
+ runs-on: ubuntu-latest
57
+ steps:
58
+ - uses: actions/checkout@v4
59
+
60
+ - name: Setup Node.js
61
+ uses: actions/setup-node@v4
62
+ with:
63
+ node-version: '20'
64
+ cache: 'npm'
65
+
66
+ - name: Install dependencies
67
+ run: npm ci
68
+
69
+ - name: Lint
70
+ run: npm run lint
71
+
72
+ - name: Type check
73
+ run: npm run type-check
74
+
75
+ - name: Lint Dockerfile
76
+ uses: hadolint/hadolint-action@v3.1.0
77
+ with:
78
+ dockerfile: Dockerfile
79
+
80
+ # ============================================
81
+ # Stage 2: Test
82
+ # ============================================
83
+ test:
84
+ name: Test
85
+ needs: validate
86
+ runs-on: ubuntu-latest
87
+
88
+ services:
89
+ postgres:
90
+ image: postgres:15
91
+ env:
92
+ POSTGRES_PASSWORD: postgres
93
+ options: >-
94
+ --health-cmd pg_isready
95
+ --health-interval 10s
96
+ --health-timeout 5s
97
+ --health-retries 5
98
+ ports:
99
+ - 5432:5432
100
+
101
+ steps:
102
+ - uses: actions/checkout@v4
103
+
104
+ - name: Setup Node.js
105
+ uses: actions/setup-node@v4
106
+ with:
107
+ node-version: '20'
108
+ cache: 'npm'
109
+
110
+ - name: Install dependencies
111
+ run: npm ci
112
+
113
+ - name: Run unit tests
114
+ run: npm run test:unit -- --coverage
115
+
116
+ - name: Run integration tests
117
+ run: npm run test:integration
118
+ env:
119
+ DATABASE_URL: postgresql://postgres:postgres@localhost:5432/test
120
+
121
+ - name: Upload coverage
122
+ uses: codecov/codecov-action@v3
123
+ with:
124
+ files: ./coverage/lcov.info
125
+ fail_ci_if_error: true
126
+
127
+ # ============================================
128
+ # Stage 3: Build
129
+ # ============================================
130
+ build:
131
+ name: Build
132
+ needs: test
133
+ runs-on: ubuntu-latest
134
+ outputs:
135
+ image-digest: ${{ steps.build.outputs.digest }}
136
+ image-tag: ${{ steps.meta.outputs.tags }}
137
+
138
+ steps:
139
+ - uses: actions/checkout@v4
140
+
141
+ - name: Set up Docker Buildx
142
+ uses: docker/setup-buildx-action@v3
143
+
144
+ - name: Login to Container Registry
145
+ uses: docker/login-action@v3
146
+ with:
147
+ registry: ${{ env.REGISTRY }}
148
+ username: ${{ github.actor }}
149
+ password: ${{ secrets.GITHUB_TOKEN }}
150
+
151
+ - name: Extract metadata
152
+ id: meta
153
+ uses: docker/metadata-action@v5
154
+ with:
155
+ images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
156
+ tags: |
157
+ type=sha,prefix=
158
+ type=ref,event=branch
159
+ type=ref,event=pr
160
+ type=semver,pattern={{version}}
161
+ type=semver,pattern={{major}}.{{minor}}
162
+
163
+ - name: Build and push
164
+ id: build
165
+ uses: docker/build-push-action@v5
166
+ with:
167
+ context: .
168
+ push: true
169
+ tags: ${{ steps.meta.outputs.tags }}
170
+ labels: ${{ steps.meta.outputs.labels }}
171
+ cache-from: type=gha
172
+ cache-to: type=gha,mode=max
173
+ provenance: true
174
+ sbom: true
175
+
176
+ # ============================================
177
+ # Stage 4: Security Scan
178
+ # ============================================
179
+ security-scan:
180
+ name: Security Scan
181
+ needs: build
182
+ runs-on: ubuntu-latest
183
+
184
+ steps:
185
+ - uses: actions/checkout@v4
186
+
187
+ - name: Run Trivy vulnerability scanner
188
+ uses: aquasecurity/trivy-action@master
189
+ with:
190
+ image-ref: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build.outputs.image-digest }}
191
+ format: 'sarif'
192
+ output: 'trivy-results.sarif'
193
+ severity: 'CRITICAL,HIGH'
194
+
195
+ - name: Upload Trivy scan results
196
+ uses: github/codeql-action/upload-sarif@v2
197
+ with:
198
+ sarif_file: 'trivy-results.sarif'
199
+
200
+ - name: Run Snyk to check for vulnerabilities
201
+ uses: snyk/actions/docker@master
202
+ env:
203
+ SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
204
+ with:
205
+ image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build.outputs.image-digest }}
206
+ args: --severity-threshold=high
207
+
208
+ # ============================================
209
+ # Stage 5: Sign Artifact
210
+ # ============================================
211
+ sign:
212
+ name: Sign Artifact
213
+ needs: [build, security-scan]
214
+ runs-on: ubuntu-latest
215
+
216
+ steps:
217
+ - name: Install Cosign
218
+ uses: sigstore/cosign-installer@v3
219
+
220
+ - name: Login to Container Registry
221
+ uses: docker/login-action@v3
222
+ with:
223
+ registry: ${{ env.REGISTRY }}
224
+ username: ${{ github.actor }}
225
+ password: ${{ secrets.GITHUB_TOKEN }}
226
+
227
+ - name: Sign container image
228
+ run: |
229
+ cosign sign --yes \
230
+ ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build.outputs.image-digest }}
231
+
232
+ # ============================================
233
+ # Stage 6: Deploy to Staging
234
+ # ============================================
235
+ deploy-staging:
236
+ name: Deploy to Staging
237
+ needs: [build, sign]
238
+ runs-on: ubuntu-latest
239
+ environment: staging
240
+
241
+ steps:
242
+ - uses: actions/checkout@v4
243
+ with:
244
+ repository: company/gitops-repo
245
+ token: ${{ secrets.GITOPS_TOKEN }}
246
+
247
+ - name: Update image tag
248
+ run: |
249
+ cd apps/api-server/overlays/staging
250
+ kustomize edit set image \
251
+ api-server=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build.outputs.image-digest }}
252
+
253
+ - name: Commit and push
254
+ run: |
255
+ git config user.name "GitHub Actions"
256
+ git config user.email "actions@github.com"
257
+ git add .
258
+ git commit -m "Deploy ${{ github.sha }} to staging"
259
+ git push
260
+
261
+ # ============================================
262
+ # Stage 7: Integration Tests
263
+ # ============================================
264
+ integration-tests:
265
+ name: Integration Tests
266
+ needs: deploy-staging
267
+ runs-on: ubuntu-latest
268
+
269
+ steps:
270
+ - uses: actions/checkout@v4
271
+
272
+ - name: Wait for deployment
273
+ run: |
274
+ kubectl rollout status deployment/api-server -n staging --timeout=300s
275
+ env:
276
+ KUBECONFIG: ${{ secrets.STAGING_KUBECONFIG }}
277
+
278
+ - name: Run E2E tests
279
+ run: npm run test:e2e
280
+ env:
281
+ TEST_URL: https://staging.example.com
282
+
283
+ # ============================================
284
+ # Stage 8: Deploy to Production
285
+ # ============================================
286
+ deploy-production:
287
+ name: Deploy to Production
288
+ needs: [build, integration-tests]
289
+ runs-on: ubuntu-latest
290
+ environment: production
291
+ if: github.ref == 'refs/heads/main' || github.event_name == 'release'
292
+
293
+ steps:
294
+ - uses: actions/checkout@v4
295
+ with:
296
+ repository: company/gitops-repo
297
+ token: ${{ secrets.GITOPS_TOKEN }}
298
+
299
+ - name: Update image tag
300
+ run: |
301
+ cd apps/api-server/overlays/production
302
+ kustomize edit set image \
303
+ api-server=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build.outputs.image-digest }}
304
+
305
+ - name: Commit and push
306
+ run: |
307
+ git config user.name "GitHub Actions"
308
+ git config user.email "actions@github.com"
309
+ git add .
310
+ git commit -m "Deploy ${{ github.sha }} to production"
311
+ git push
312
+ ```
313
+
314
+ ## GitOps with Argo CD
315
+
316
+ ### Application Definition
317
+
318
+ ```yaml
319
+ apiVersion: argoproj.io/v1alpha1
320
+ kind: Application
321
+ metadata:
322
+ name: api-server
323
+ namespace: argocd
324
+ finalizers:
325
+ - resources-finalizer.argocd.argoproj.io
326
+ spec:
327
+ project: production
328
+
329
+ source:
330
+ repoURL: https://github.com/company/gitops-repo.git
331
+ targetRevision: HEAD
332
+ path: apps/api-server/overlays/production
333
+
334
+ destination:
335
+ server: https://kubernetes.default.svc
336
+ namespace: production
337
+
338
+ syncPolicy:
339
+ automated:
340
+ prune: true
341
+ selfHeal: true
342
+ allowEmpty: false
343
+ syncOptions:
344
+ - CreateNamespace=true
345
+ - PruneLast=true
346
+ - ServerSideApply=true
347
+ retry:
348
+ limit: 5
349
+ backoff:
350
+ duration: 5s
351
+ factor: 2
352
+ maxDuration: 3m
353
+
354
+ # Health checks
355
+ ignoreDifferences:
356
+ - group: apps
357
+ kind: Deployment
358
+ jsonPointers:
359
+ - /spec/replicas # Ignore HPA changes
360
+ ```
361
+
362
+ ### ApplicationSet for Multi-Environment
363
+
364
+ ```yaml
365
+ apiVersion: argoproj.io/v1alpha1
366
+ kind: ApplicationSet
367
+ metadata:
368
+ name: api-server
369
+ namespace: argocd
370
+ spec:
371
+ generators:
372
+ - git:
373
+ repoURL: https://github.com/company/gitops-repo.git
374
+ revision: HEAD
375
+ directories:
376
+ - path: apps/api-server/overlays/*
377
+
378
+ template:
379
+ metadata:
380
+ name: 'api-server-{{path.basename}}'
381
+ labels:
382
+ app: api-server
383
+ environment: '{{path.basename}}'
384
+ spec:
385
+ project: '{{path.basename}}'
386
+ source:
387
+ repoURL: https://github.com/company/gitops-repo.git
388
+ targetRevision: HEAD
389
+ path: '{{path}}'
390
+ destination:
391
+ server: https://kubernetes.default.svc
392
+ namespace: '{{path.basename}}'
393
+ syncPolicy:
394
+ automated:
395
+ prune: true
396
+ selfHeal: true
397
+ ```
398
+
399
+ ### Argo CD Project
400
+
401
+ ```yaml
402
+ apiVersion: argoproj.io/v1alpha1
403
+ kind: AppProject
404
+ metadata:
405
+ name: production
406
+ namespace: argocd
407
+ spec:
408
+ description: Production applications
409
+
410
+ sourceRepos:
411
+ - https://github.com/company/gitops-repo.git
412
+ - https://charts.example.com
413
+
414
+ destinations:
415
+ - namespace: production
416
+ server: https://kubernetes.default.svc
417
+ - namespace: production-*
418
+ server: https://kubernetes.default.svc
419
+
420
+ clusterResourceWhitelist:
421
+ - group: ''
422
+ kind: Namespace
423
+
424
+ namespaceResourceBlacklist:
425
+ - group: ''
426
+ kind: ResourceQuota
427
+ - group: ''
428
+ kind: LimitRange
429
+
430
+ roles:
431
+ - name: developer
432
+ description: Developer access
433
+ policies:
434
+ - p, proj:production:developer, applications, get, production/*, allow
435
+ - p, proj:production:developer, applications, sync, production/*, allow
436
+ groups:
437
+ - developers
438
+ ```
439
+
440
+ ## Deployment Strategies
441
+
442
+ ### Blue-Green Deployment
443
+
444
+ ```yaml
445
+ # Argo Rollouts Blue-Green
446
+ apiVersion: argoproj.io/v1alpha1
447
+ kind: Rollout
448
+ metadata:
449
+ name: api-server
450
+ spec:
451
+ replicas: 5
452
+ selector:
453
+ matchLabels:
454
+ app: api-server
455
+ template:
456
+ metadata:
457
+ labels:
458
+ app: api-server
459
+ spec:
460
+ containers:
461
+ - name: api-server
462
+ image: company/api-server:v1.2.3
463
+
464
+ strategy:
465
+ blueGreen:
466
+ activeService: api-server
467
+ previewService: api-server-preview
468
+ autoPromotionEnabled: false
469
+ prePromotionAnalysis:
470
+ templates:
471
+ - templateName: success-rate
472
+ args:
473
+ - name: service-name
474
+ value: api-server-preview
475
+ ```
476
+
477
+ ### Canary Deployment
478
+
479
+ ```yaml
480
+ # Argo Rollouts Canary
481
+ apiVersion: argoproj.io/v1alpha1
482
+ kind: Rollout
483
+ metadata:
484
+ name: api-server
485
+ spec:
486
+ replicas: 10
487
+ selector:
488
+ matchLabels:
489
+ app: api-server
490
+ template:
491
+ metadata:
492
+ labels:
493
+ app: api-server
494
+ spec:
495
+ containers:
496
+ - name: api-server
497
+ image: company/api-server:v1.2.3
498
+
499
+ strategy:
500
+ canary:
501
+ steps:
502
+ - setWeight: 10
503
+ - pause: { duration: 5m }
504
+ - setWeight: 20
505
+ - pause: { duration: 5m }
506
+ - setWeight: 50
507
+ - pause: { duration: 10m }
508
+ - setWeight: 100
509
+
510
+ # Traffic management
511
+ trafficRouting:
512
+ istio:
513
+ virtualService:
514
+ name: api-server
515
+ routes:
516
+ - primary
517
+
518
+ # Analysis during rollout
519
+ analysis:
520
+ templates:
521
+ - templateName: success-rate
522
+ - templateName: latency
523
+ startingStep: 1
524
+ args:
525
+ - name: service-name
526
+ value: api-server
527
+ ```
528
+
529
+ ### Analysis Template
530
+
531
+ ```yaml
532
+ apiVersion: argoproj.io/v1alpha1
533
+ kind: AnalysisTemplate
534
+ metadata:
535
+ name: success-rate
536
+ spec:
537
+ args:
538
+ - name: service-name
539
+ metrics:
540
+ - name: success-rate
541
+ interval: 1m
542
+ successCondition: result[0] >= 0.99
543
+ failureLimit: 3
544
+ provider:
545
+ prometheus:
546
+ address: http://prometheus.monitoring:9090
547
+ query: |
548
+ sum(rate(http_requests_total{service="{{args.service-name}}",status!~"5.."}[5m]))
549
+ /
550
+ sum(rate(http_requests_total{service="{{args.service-name}}"}[5m]))
551
+ ```
552
+
553
+ ## Reusable Pipeline Components
554
+
555
+ ### Composite Action
556
+
557
+ ```yaml
558
+ # .github/actions/docker-build/action.yml
559
+ name: Docker Build and Push
560
+ description: Build and push Docker image with best practices
561
+
562
+ inputs:
563
+ registry:
564
+ description: Container registry
565
+ required: true
566
+ image-name:
567
+ description: Image name
568
+ required: true
569
+ dockerfile:
570
+ description: Path to Dockerfile
571
+ default: Dockerfile
572
+
573
+ outputs:
574
+ digest:
575
+ description: Image digest
576
+ value: ${{ steps.build.outputs.digest }}
577
+ tags:
578
+ description: Image tags
579
+ value: ${{ steps.meta.outputs.tags }}
580
+
581
+ runs:
582
+ using: composite
583
+ steps:
584
+ - name: Set up Docker Buildx
585
+ uses: docker/setup-buildx-action@v3
586
+
587
+ - name: Extract metadata
588
+ id: meta
589
+ uses: docker/metadata-action@v5
590
+ with:
591
+ images: ${{ inputs.registry }}/${{ inputs.image-name }}
592
+ tags: |
593
+ type=sha,prefix=
594
+ type=ref,event=branch
595
+ type=semver,pattern={{version}}
596
+
597
+ - name: Build and push
598
+ id: build
599
+ uses: docker/build-push-action@v5
600
+ with:
601
+ context: .
602
+ file: ${{ inputs.dockerfile }}
603
+ push: true
604
+ tags: ${{ steps.meta.outputs.tags }}
605
+ cache-from: type=gha
606
+ cache-to: type=gha,mode=max
607
+ ```
608
+
609
+ ### Reusable Workflow
610
+
611
+ ```yaml
612
+ # .github/workflows/reusable-deploy.yml
613
+ name: Reusable Deploy
614
+
615
+ on:
616
+ workflow_call:
617
+ inputs:
618
+ environment:
619
+ required: true
620
+ type: string
621
+ image-digest:
622
+ required: true
623
+ type: string
624
+ secrets:
625
+ GITOPS_TOKEN:
626
+ required: true
627
+
628
+ jobs:
629
+ deploy:
630
+ runs-on: ubuntu-latest
631
+ environment: ${{ inputs.environment }}
632
+
633
+ steps:
634
+ - uses: actions/checkout@v4
635
+ with:
636
+ repository: company/gitops-repo
637
+ token: ${{ secrets.GITOPS_TOKEN }}
638
+
639
+ - name: Update manifest
640
+ run: |
641
+ cd apps/api-server/overlays/${{ inputs.environment }}
642
+ kustomize edit set image api-server=ghcr.io/company/api-server@${{ inputs.image-digest }}
643
+
644
+ - name: Commit and push
645
+ run: |
646
+ git config user.name "GitHub Actions"
647
+ git config user.email "actions@github.com"
648
+ git add .
649
+ git commit -m "Deploy to ${{ inputs.environment }}"
650
+ git push
651
+ ```
652
+
653
+ ## Secret Management in Pipelines
654
+
655
+ ### OIDC Authentication
656
+
657
+ ```yaml
658
+ # AWS OIDC authentication - no long-lived credentials
659
+ permissions:
660
+ id-token: write
661
+ contents: read
662
+
663
+ jobs:
664
+ deploy:
665
+ runs-on: ubuntu-latest
666
+ steps:
667
+ - name: Configure AWS credentials
668
+ uses: aws-actions/configure-aws-credentials@v4
669
+ with:
670
+ role-to-assume: arn:aws:iam::123456789012:role/GitHubActions
671
+ aws-region: us-east-1
672
+ ```
673
+
674
+ ### Sealed Secrets
675
+
676
+ ```yaml
677
+ # Create sealed secret
678
+ apiVersion: bitnami.com/v1alpha1
679
+ kind: SealedSecret
680
+ metadata:
681
+ name: api-secrets
682
+ namespace: production
683
+ spec:
684
+ encryptedData:
685
+ API_KEY: AgBy8...encrypted...data==
686
+ DATABASE_URL: AgDK3...encrypted...data==
687
+ ```
688
+
689
+ ## Artifact Management
690
+
691
+ ### Container Image Lifecycle
692
+
693
+ ```yaml
694
+ # GitHub Container Registry cleanup
695
+ name: Cleanup old images
696
+
697
+ on:
698
+ schedule:
699
+ - cron: '0 0 * * 0' # Weekly
700
+
701
+ jobs:
702
+ cleanup:
703
+ runs-on: ubuntu-latest
704
+ steps:
705
+ - uses: actions/delete-package-versions@v4
706
+ with:
707
+ package-name: api-server
708
+ package-type: container
709
+ min-versions-to-keep: 10
710
+ delete-only-untagged-versions: true
711
+ ```
712
+
713
+ ## Common Pitfalls
714
+
715
+ ### 1. Long-Running Pipelines
716
+
717
+ ```yaml
718
+ # Bad - sequential stages that could run in parallel
719
+ jobs:
720
+ lint:
721
+ ...
722
+ test:
723
+ needs: lint
724
+ ...
725
+ security:
726
+ needs: test
727
+ ...
728
+
729
+ # Good - parallel stages where possible
730
+ jobs:
731
+ lint:
732
+ ...
733
+ test:
734
+ ...
735
+ security:
736
+ ...
737
+ build:
738
+ needs: [lint, test, security]
739
+ ```
740
+
741
+ ### 2. No Pipeline Caching
742
+
743
+ ```yaml
744
+ # Bad - reinstall dependencies every time
745
+ steps:
746
+ - run: npm install
747
+
748
+ # Good - cache dependencies
749
+ steps:
750
+ - uses: actions/setup-node@v4
751
+ with:
752
+ cache: 'npm'
753
+ - run: npm ci
754
+ ```
755
+
756
+ ### 3. Missing Timeouts
757
+
758
+ ```yaml
759
+ # Always set timeouts
760
+ jobs:
761
+ test:
762
+ runs-on: ubuntu-latest
763
+ timeout-minutes: 30
764
+ steps:
765
+ - name: Run tests
766
+ timeout-minutes: 20
767
+ run: npm test
768
+ ```
769
+
770
+ ### 4. Hardcoded Values
771
+
772
+ ```yaml
773
+ # Bad
774
+ run: docker push myregistry.io/myapp:v1.2.3
775
+
776
+ # Good
777
+ run: docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
778
+ ```