@corbat-tech/coding-standards-mcp 1.0.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/LICENSE +21 -0
- package/README.md +371 -0
- package/assets/demo.gif +0 -0
- package/dist/agent.d.ts +53 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +629 -0
- package/dist/agent.js.map +1 -0
- package/dist/cli/init.d.ts +3 -0
- package/dist/cli/init.d.ts.map +1 -0
- package/dist/cli/init.js +651 -0
- package/dist/cli/init.js.map +1 -0
- package/dist/config.d.ts +73 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +105 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +73 -0
- package/dist/index.js.map +1 -0
- package/dist/profiles.d.ts +39 -0
- package/dist/profiles.d.ts.map +1 -0
- package/dist/profiles.js +526 -0
- package/dist/profiles.js.map +1 -0
- package/dist/prompts-legacy.d.ts +25 -0
- package/dist/prompts-legacy.d.ts.map +1 -0
- package/dist/prompts-legacy.js +600 -0
- package/dist/prompts-legacy.js.map +1 -0
- package/dist/prompts-v2.d.ts +30 -0
- package/dist/prompts-v2.d.ts.map +1 -0
- package/dist/prompts-v2.js +310 -0
- package/dist/prompts-v2.js.map +1 -0
- package/dist/prompts.d.ts +30 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +310 -0
- package/dist/prompts.js.map +1 -0
- package/dist/resources.d.ts +18 -0
- package/dist/resources.d.ts.map +1 -0
- package/dist/resources.js +95 -0
- package/dist/resources.js.map +1 -0
- package/dist/tools-legacy.d.ts +196 -0
- package/dist/tools-legacy.d.ts.map +1 -0
- package/dist/tools-legacy.js +1230 -0
- package/dist/tools-legacy.js.map +1 -0
- package/dist/tools-v2.d.ts +92 -0
- package/dist/tools-v2.d.ts.map +1 -0
- package/dist/tools-v2.js +410 -0
- package/dist/tools-v2.js.map +1 -0
- package/dist/tools.d.ts +92 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +410 -0
- package/dist/tools.js.map +1 -0
- package/dist/types.d.ts +3054 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +515 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +5 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/retry.d.ts +44 -0
- package/dist/utils/retry.d.ts.map +1 -0
- package/dist/utils/retry.js +74 -0
- package/dist/utils/retry.js.map +1 -0
- package/package.json +79 -0
- package/profiles/README.md +199 -0
- package/profiles/custom/.gitkeep +2 -0
- package/profiles/templates/_template.yaml +159 -0
- package/profiles/templates/angular.yaml +494 -0
- package/profiles/templates/java-spring-backend.yaml +512 -0
- package/profiles/templates/minimal.yaml +102 -0
- package/profiles/templates/nodejs.yaml +338 -0
- package/profiles/templates/python.yaml +340 -0
- package/profiles/templates/react.yaml +331 -0
- package/profiles/templates/vue.yaml +598 -0
- package/standards/architecture/ddd.md +173 -0
- package/standards/architecture/hexagonal.md +97 -0
- package/standards/cicd/github-actions.md +567 -0
- package/standards/clean-code/naming.md +175 -0
- package/standards/clean-code/principles.md +179 -0
- package/standards/containerization/dockerfile.md +419 -0
- package/standards/database/selection-guide.md +443 -0
- package/standards/documentation/guidelines.md +189 -0
- package/standards/event-driven/domain-events.md +527 -0
- package/standards/kubernetes/deployment.md +518 -0
- package/standards/observability/guidelines.md +665 -0
- package/standards/project-setup/initialization-checklist.md +650 -0
- package/standards/spring-boot/best-practices.md +598 -0
- package/standards/testing/guidelines.md +559 -0
- package/standards/workflow/llm-development-workflow.md +542 -0
|
@@ -0,0 +1,567 @@
|
|
|
1
|
+
# CI/CD with GitHub Actions
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Guidelines for implementing CI/CD pipelines with GitHub Actions for Spring Boot applications.
|
|
6
|
+
|
|
7
|
+
## Directory Structure
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
.github/
|
|
11
|
+
├── workflows/
|
|
12
|
+
│ ├── ci.yml # Main CI pipeline
|
|
13
|
+
│ ├── cd.yml # Deployment pipeline
|
|
14
|
+
│ ├── pr.yml # Pull request checks
|
|
15
|
+
│ └── release.yml # Release workflow
|
|
16
|
+
├── actions/
|
|
17
|
+
│ └── setup-java/ # Reusable action
|
|
18
|
+
│ └── action.yml
|
|
19
|
+
└── CODEOWNERS
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## CI Pipeline (ci.yml)
|
|
23
|
+
|
|
24
|
+
```yaml
|
|
25
|
+
name: CI
|
|
26
|
+
|
|
27
|
+
on:
|
|
28
|
+
push:
|
|
29
|
+
branches: [main, develop]
|
|
30
|
+
pull_request:
|
|
31
|
+
branches: [main, develop]
|
|
32
|
+
|
|
33
|
+
env:
|
|
34
|
+
JAVA_VERSION: '21'
|
|
35
|
+
REGISTRY: ghcr.io
|
|
36
|
+
IMAGE_NAME: ${{ github.repository }}
|
|
37
|
+
|
|
38
|
+
jobs:
|
|
39
|
+
# ============================================
|
|
40
|
+
# Build and Test
|
|
41
|
+
# ============================================
|
|
42
|
+
build:
|
|
43
|
+
name: Build and Test
|
|
44
|
+
runs-on: ubuntu-latest
|
|
45
|
+
permissions:
|
|
46
|
+
contents: read
|
|
47
|
+
checks: write
|
|
48
|
+
|
|
49
|
+
steps:
|
|
50
|
+
- name: Checkout
|
|
51
|
+
uses: actions/checkout@v4
|
|
52
|
+
|
|
53
|
+
- name: Set up JDK
|
|
54
|
+
uses: actions/setup-java@v4
|
|
55
|
+
with:
|
|
56
|
+
java-version: ${{ env.JAVA_VERSION }}
|
|
57
|
+
distribution: 'temurin'
|
|
58
|
+
cache: 'maven'
|
|
59
|
+
|
|
60
|
+
- name: Build with Maven
|
|
61
|
+
run: ./mvnw clean verify -B
|
|
62
|
+
|
|
63
|
+
- name: Publish Test Results
|
|
64
|
+
uses: EnricoMi/publish-unit-test-result-action@v2
|
|
65
|
+
if: always()
|
|
66
|
+
with:
|
|
67
|
+
files: |
|
|
68
|
+
target/surefire-reports/*.xml
|
|
69
|
+
target/failsafe-reports/*.xml
|
|
70
|
+
|
|
71
|
+
- name: Upload Coverage to Codecov
|
|
72
|
+
uses: codecov/codecov-action@v4
|
|
73
|
+
with:
|
|
74
|
+
files: target/site/jacoco/jacoco.xml
|
|
75
|
+
fail_ci_if_error: true
|
|
76
|
+
|
|
77
|
+
- name: Cache Maven packages
|
|
78
|
+
uses: actions/cache@v4
|
|
79
|
+
with:
|
|
80
|
+
path: ~/.m2
|
|
81
|
+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
|
|
82
|
+
restore-keys: ${{ runner.os }}-m2
|
|
83
|
+
|
|
84
|
+
# ============================================
|
|
85
|
+
# Code Quality
|
|
86
|
+
# ============================================
|
|
87
|
+
code-quality:
|
|
88
|
+
name: Code Quality
|
|
89
|
+
runs-on: ubuntu-latest
|
|
90
|
+
needs: build
|
|
91
|
+
|
|
92
|
+
steps:
|
|
93
|
+
- name: Checkout
|
|
94
|
+
uses: actions/checkout@v4
|
|
95
|
+
with:
|
|
96
|
+
fetch-depth: 0
|
|
97
|
+
|
|
98
|
+
- name: Set up JDK
|
|
99
|
+
uses: actions/setup-java@v4
|
|
100
|
+
with:
|
|
101
|
+
java-version: ${{ env.JAVA_VERSION }}
|
|
102
|
+
distribution: 'temurin'
|
|
103
|
+
cache: 'maven'
|
|
104
|
+
|
|
105
|
+
- name: SonarCloud Scan
|
|
106
|
+
env:
|
|
107
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
108
|
+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
|
109
|
+
run: ./mvnw verify sonar:sonar -B -DskipTests
|
|
110
|
+
|
|
111
|
+
# ============================================
|
|
112
|
+
# Security Scan
|
|
113
|
+
# ============================================
|
|
114
|
+
security:
|
|
115
|
+
name: Security Scan
|
|
116
|
+
runs-on: ubuntu-latest
|
|
117
|
+
needs: build
|
|
118
|
+
permissions:
|
|
119
|
+
security-events: write
|
|
120
|
+
|
|
121
|
+
steps:
|
|
122
|
+
- name: Checkout
|
|
123
|
+
uses: actions/checkout@v4
|
|
124
|
+
|
|
125
|
+
- name: Set up JDK
|
|
126
|
+
uses: actions/setup-java@v4
|
|
127
|
+
with:
|
|
128
|
+
java-version: ${{ env.JAVA_VERSION }}
|
|
129
|
+
distribution: 'temurin'
|
|
130
|
+
cache: 'maven'
|
|
131
|
+
|
|
132
|
+
- name: OWASP Dependency Check
|
|
133
|
+
run: ./mvnw org.owasp:dependency-check-maven:check -B
|
|
134
|
+
|
|
135
|
+
- name: Upload Dependency Check Report
|
|
136
|
+
uses: github/codeql-action/upload-sarif@v3
|
|
137
|
+
if: always()
|
|
138
|
+
with:
|
|
139
|
+
sarif_file: target/dependency-check-report.sarif
|
|
140
|
+
|
|
141
|
+
# ============================================
|
|
142
|
+
# Build and Push Docker Image
|
|
143
|
+
# ============================================
|
|
144
|
+
docker:
|
|
145
|
+
name: Build Docker Image
|
|
146
|
+
runs-on: ubuntu-latest
|
|
147
|
+
needs: [build, code-quality, security]
|
|
148
|
+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
149
|
+
permissions:
|
|
150
|
+
contents: read
|
|
151
|
+
packages: write
|
|
152
|
+
|
|
153
|
+
outputs:
|
|
154
|
+
image-tag: ${{ steps.meta.outputs.tags }}
|
|
155
|
+
image-digest: ${{ steps.build-push.outputs.digest }}
|
|
156
|
+
|
|
157
|
+
steps:
|
|
158
|
+
- name: Checkout
|
|
159
|
+
uses: actions/checkout@v4
|
|
160
|
+
|
|
161
|
+
- name: Set up JDK
|
|
162
|
+
uses: actions/setup-java@v4
|
|
163
|
+
with:
|
|
164
|
+
java-version: ${{ env.JAVA_VERSION }}
|
|
165
|
+
distribution: 'temurin'
|
|
166
|
+
cache: 'maven'
|
|
167
|
+
|
|
168
|
+
- name: Build JAR
|
|
169
|
+
run: ./mvnw package -DskipTests -B
|
|
170
|
+
|
|
171
|
+
- name: Set up Docker Buildx
|
|
172
|
+
uses: docker/setup-buildx-action@v3
|
|
173
|
+
|
|
174
|
+
- name: Login to Container Registry
|
|
175
|
+
uses: docker/login-action@v3
|
|
176
|
+
with:
|
|
177
|
+
registry: ${{ env.REGISTRY }}
|
|
178
|
+
username: ${{ github.actor }}
|
|
179
|
+
password: ${{ secrets.GITHUB_TOKEN }}
|
|
180
|
+
|
|
181
|
+
- name: Extract metadata
|
|
182
|
+
id: meta
|
|
183
|
+
uses: docker/metadata-action@v5
|
|
184
|
+
with:
|
|
185
|
+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
186
|
+
tags: |
|
|
187
|
+
type=sha,prefix=
|
|
188
|
+
type=ref,event=branch
|
|
189
|
+
type=semver,pattern={{version}}
|
|
190
|
+
|
|
191
|
+
- name: Build and push
|
|
192
|
+
id: build-push
|
|
193
|
+
uses: docker/build-push-action@v5
|
|
194
|
+
with:
|
|
195
|
+
context: .
|
|
196
|
+
push: true
|
|
197
|
+
tags: ${{ steps.meta.outputs.tags }}
|
|
198
|
+
labels: ${{ steps.meta.outputs.labels }}
|
|
199
|
+
cache-from: type=gha
|
|
200
|
+
cache-to: type=gha,mode=max
|
|
201
|
+
provenance: true
|
|
202
|
+
sbom: true
|
|
203
|
+
|
|
204
|
+
- name: Scan Docker Image
|
|
205
|
+
uses: aquasecurity/trivy-action@master
|
|
206
|
+
with:
|
|
207
|
+
image-ref: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
|
|
208
|
+
format: 'sarif'
|
|
209
|
+
output: 'trivy-results.sarif'
|
|
210
|
+
|
|
211
|
+
- name: Upload Trivy scan results
|
|
212
|
+
uses: github/codeql-action/upload-sarif@v3
|
|
213
|
+
with:
|
|
214
|
+
sarif_file: 'trivy-results.sarif'
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## CD Pipeline (cd.yml)
|
|
218
|
+
|
|
219
|
+
```yaml
|
|
220
|
+
name: CD
|
|
221
|
+
|
|
222
|
+
on:
|
|
223
|
+
workflow_run:
|
|
224
|
+
workflows: [CI]
|
|
225
|
+
types: [completed]
|
|
226
|
+
branches: [main]
|
|
227
|
+
|
|
228
|
+
env:
|
|
229
|
+
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
|
|
230
|
+
|
|
231
|
+
jobs:
|
|
232
|
+
deploy-staging:
|
|
233
|
+
name: Deploy to Staging
|
|
234
|
+
runs-on: ubuntu-latest
|
|
235
|
+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
|
236
|
+
environment:
|
|
237
|
+
name: staging
|
|
238
|
+
url: https://staging.example.com
|
|
239
|
+
|
|
240
|
+
steps:
|
|
241
|
+
- name: Checkout
|
|
242
|
+
uses: actions/checkout@v4
|
|
243
|
+
|
|
244
|
+
- name: Setup kubectl
|
|
245
|
+
uses: azure/setup-kubectl@v4
|
|
246
|
+
|
|
247
|
+
- name: Configure kubeconfig
|
|
248
|
+
run: |
|
|
249
|
+
mkdir -p ~/.kube
|
|
250
|
+
echo "${{ secrets.KUBE_CONFIG_STAGING }}" > ~/.kube/config
|
|
251
|
+
|
|
252
|
+
- name: Update image tag
|
|
253
|
+
run: |
|
|
254
|
+
cd infrastructure/kubernetes/overlays/staging
|
|
255
|
+
kustomize edit set image order-service=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
|
|
256
|
+
|
|
257
|
+
- name: Deploy to Staging
|
|
258
|
+
run: |
|
|
259
|
+
kubectl apply -k infrastructure/kubernetes/overlays/staging
|
|
260
|
+
kubectl rollout status deployment/order-service -n staging --timeout=300s
|
|
261
|
+
|
|
262
|
+
- name: Run Smoke Tests
|
|
263
|
+
run: |
|
|
264
|
+
./scripts/smoke-test.sh https://staging.example.com
|
|
265
|
+
|
|
266
|
+
deploy-production:
|
|
267
|
+
name: Deploy to Production
|
|
268
|
+
runs-on: ubuntu-latest
|
|
269
|
+
needs: deploy-staging
|
|
270
|
+
environment:
|
|
271
|
+
name: production
|
|
272
|
+
url: https://api.example.com
|
|
273
|
+
|
|
274
|
+
steps:
|
|
275
|
+
- name: Checkout
|
|
276
|
+
uses: actions/checkout@v4
|
|
277
|
+
|
|
278
|
+
- name: Setup kubectl
|
|
279
|
+
uses: azure/setup-kubectl@v4
|
|
280
|
+
|
|
281
|
+
- name: Configure kubeconfig
|
|
282
|
+
run: |
|
|
283
|
+
mkdir -p ~/.kube
|
|
284
|
+
echo "${{ secrets.KUBE_CONFIG_PRODUCTION }}" > ~/.kube/config
|
|
285
|
+
|
|
286
|
+
- name: Update image tag
|
|
287
|
+
run: |
|
|
288
|
+
cd infrastructure/kubernetes/overlays/production
|
|
289
|
+
kustomize edit set image order-service=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
|
|
290
|
+
|
|
291
|
+
- name: Deploy to Production
|
|
292
|
+
run: |
|
|
293
|
+
kubectl apply -k infrastructure/kubernetes/overlays/production
|
|
294
|
+
kubectl rollout status deployment/order-service -n production --timeout=300s
|
|
295
|
+
|
|
296
|
+
- name: Verify Deployment
|
|
297
|
+
run: |
|
|
298
|
+
./scripts/verify-deployment.sh https://api.example.com
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
## Pull Request Workflow (pr.yml)
|
|
302
|
+
|
|
303
|
+
```yaml
|
|
304
|
+
name: PR Checks
|
|
305
|
+
|
|
306
|
+
on:
|
|
307
|
+
pull_request:
|
|
308
|
+
types: [opened, synchronize, reopened]
|
|
309
|
+
|
|
310
|
+
jobs:
|
|
311
|
+
lint:
|
|
312
|
+
name: Lint
|
|
313
|
+
runs-on: ubuntu-latest
|
|
314
|
+
|
|
315
|
+
steps:
|
|
316
|
+
- name: Checkout
|
|
317
|
+
uses: actions/checkout@v4
|
|
318
|
+
|
|
319
|
+
- name: Set up JDK
|
|
320
|
+
uses: actions/setup-java@v4
|
|
321
|
+
with:
|
|
322
|
+
java-version: '21'
|
|
323
|
+
distribution: 'temurin'
|
|
324
|
+
cache: 'maven'
|
|
325
|
+
|
|
326
|
+
- name: Check formatting
|
|
327
|
+
run: ./mvnw spotless:check -B
|
|
328
|
+
|
|
329
|
+
- name: Check for secrets
|
|
330
|
+
uses: trufflesecurity/trufflehog@main
|
|
331
|
+
with:
|
|
332
|
+
path: ./
|
|
333
|
+
base: ${{ github.event.pull_request.base.sha }}
|
|
334
|
+
head: ${{ github.event.pull_request.head.sha }}
|
|
335
|
+
|
|
336
|
+
test:
|
|
337
|
+
name: Test
|
|
338
|
+
runs-on: ubuntu-latest
|
|
339
|
+
|
|
340
|
+
services:
|
|
341
|
+
postgres:
|
|
342
|
+
image: postgres:15-alpine
|
|
343
|
+
env:
|
|
344
|
+
POSTGRES_DB: testdb
|
|
345
|
+
POSTGRES_USER: test
|
|
346
|
+
POSTGRES_PASSWORD: test
|
|
347
|
+
ports:
|
|
348
|
+
- 5432:5432
|
|
349
|
+
options: >-
|
|
350
|
+
--health-cmd pg_isready
|
|
351
|
+
--health-interval 10s
|
|
352
|
+
--health-timeout 5s
|
|
353
|
+
--health-retries 5
|
|
354
|
+
|
|
355
|
+
steps:
|
|
356
|
+
- name: Checkout
|
|
357
|
+
uses: actions/checkout@v4
|
|
358
|
+
|
|
359
|
+
- name: Set up JDK
|
|
360
|
+
uses: actions/setup-java@v4
|
|
361
|
+
with:
|
|
362
|
+
java-version: '21'
|
|
363
|
+
distribution: 'temurin'
|
|
364
|
+
cache: 'maven'
|
|
365
|
+
|
|
366
|
+
- name: Run tests
|
|
367
|
+
env:
|
|
368
|
+
DATABASE_URL: jdbc:postgresql://localhost:5432/testdb
|
|
369
|
+
DATABASE_USERNAME: test
|
|
370
|
+
DATABASE_PASSWORD: test
|
|
371
|
+
run: ./mvnw verify -B
|
|
372
|
+
|
|
373
|
+
- name: Add coverage comment
|
|
374
|
+
uses: MishaKav/jest-coverage-comment@main
|
|
375
|
+
if: github.event_name == 'pull_request'
|
|
376
|
+
with:
|
|
377
|
+
coverage-summary-path: target/site/jacoco/jacoco.csv
|
|
378
|
+
title: Test Coverage
|
|
379
|
+
badge-title: Coverage
|
|
380
|
+
|
|
381
|
+
architecture:
|
|
382
|
+
name: Architecture Tests
|
|
383
|
+
runs-on: ubuntu-latest
|
|
384
|
+
|
|
385
|
+
steps:
|
|
386
|
+
- name: Checkout
|
|
387
|
+
uses: actions/checkout@v4
|
|
388
|
+
|
|
389
|
+
- name: Set up JDK
|
|
390
|
+
uses: actions/setup-java@v4
|
|
391
|
+
with:
|
|
392
|
+
java-version: '21'
|
|
393
|
+
distribution: 'temurin'
|
|
394
|
+
cache: 'maven'
|
|
395
|
+
|
|
396
|
+
- name: Run ArchUnit tests
|
|
397
|
+
run: ./mvnw test -Dtest="*ArchTest" -B
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
## Release Workflow (release.yml)
|
|
401
|
+
|
|
402
|
+
```yaml
|
|
403
|
+
name: Release
|
|
404
|
+
|
|
405
|
+
on:
|
|
406
|
+
push:
|
|
407
|
+
tags:
|
|
408
|
+
- 'v*'
|
|
409
|
+
|
|
410
|
+
permissions:
|
|
411
|
+
contents: write
|
|
412
|
+
packages: write
|
|
413
|
+
|
|
414
|
+
jobs:
|
|
415
|
+
release:
|
|
416
|
+
name: Create Release
|
|
417
|
+
runs-on: ubuntu-latest
|
|
418
|
+
|
|
419
|
+
steps:
|
|
420
|
+
- name: Checkout
|
|
421
|
+
uses: actions/checkout@v4
|
|
422
|
+
with:
|
|
423
|
+
fetch-depth: 0
|
|
424
|
+
|
|
425
|
+
- name: Set up JDK
|
|
426
|
+
uses: actions/setup-java@v4
|
|
427
|
+
with:
|
|
428
|
+
java-version: '21'
|
|
429
|
+
distribution: 'temurin'
|
|
430
|
+
cache: 'maven'
|
|
431
|
+
|
|
432
|
+
- name: Set version from tag
|
|
433
|
+
run: |
|
|
434
|
+
VERSION=${GITHUB_REF#refs/tags/v}
|
|
435
|
+
./mvnw versions:set -DnewVersion=$VERSION -B
|
|
436
|
+
|
|
437
|
+
- name: Build release
|
|
438
|
+
run: ./mvnw clean package -DskipTests -B
|
|
439
|
+
|
|
440
|
+
- name: Build and push Docker image
|
|
441
|
+
uses: docker/build-push-action@v5
|
|
442
|
+
with:
|
|
443
|
+
context: .
|
|
444
|
+
push: true
|
|
445
|
+
tags: |
|
|
446
|
+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}
|
|
447
|
+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
|
448
|
+
|
|
449
|
+
- name: Generate changelog
|
|
450
|
+
id: changelog
|
|
451
|
+
uses: orhun/git-cliff-action@v3
|
|
452
|
+
with:
|
|
453
|
+
config: cliff.toml
|
|
454
|
+
args: --current
|
|
455
|
+
|
|
456
|
+
- name: Create GitHub Release
|
|
457
|
+
uses: softprops/action-gh-release@v1
|
|
458
|
+
with:
|
|
459
|
+
body: ${{ steps.changelog.outputs.content }}
|
|
460
|
+
files: |
|
|
461
|
+
target/*.jar
|
|
462
|
+
generate_release_notes: true
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
## Reusable Workflow
|
|
466
|
+
|
|
467
|
+
```yaml
|
|
468
|
+
# .github/workflows/deploy-service.yml
|
|
469
|
+
name: Deploy Service
|
|
470
|
+
|
|
471
|
+
on:
|
|
472
|
+
workflow_call:
|
|
473
|
+
inputs:
|
|
474
|
+
environment:
|
|
475
|
+
required: true
|
|
476
|
+
type: string
|
|
477
|
+
image-tag:
|
|
478
|
+
required: true
|
|
479
|
+
type: string
|
|
480
|
+
secrets:
|
|
481
|
+
KUBE_CONFIG:
|
|
482
|
+
required: true
|
|
483
|
+
|
|
484
|
+
jobs:
|
|
485
|
+
deploy:
|
|
486
|
+
runs-on: ubuntu-latest
|
|
487
|
+
environment: ${{ inputs.environment }}
|
|
488
|
+
|
|
489
|
+
steps:
|
|
490
|
+
- name: Checkout
|
|
491
|
+
uses: actions/checkout@v4
|
|
492
|
+
|
|
493
|
+
- name: Setup kubectl
|
|
494
|
+
uses: azure/setup-kubectl@v4
|
|
495
|
+
|
|
496
|
+
- name: Deploy
|
|
497
|
+
run: |
|
|
498
|
+
echo "${{ secrets.KUBE_CONFIG }}" > ~/.kube/config
|
|
499
|
+
kustomize build infrastructure/kubernetes/overlays/${{ inputs.environment }} | \
|
|
500
|
+
kubectl apply -f -
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
## Matrix Testing
|
|
504
|
+
|
|
505
|
+
```yaml
|
|
506
|
+
jobs:
|
|
507
|
+
test-matrix:
|
|
508
|
+
name: Test on ${{ matrix.os }} with Java ${{ matrix.java }}
|
|
509
|
+
runs-on: ${{ matrix.os }}
|
|
510
|
+
strategy:
|
|
511
|
+
matrix:
|
|
512
|
+
os: [ubuntu-latest, macos-latest]
|
|
513
|
+
java: ['17', '21']
|
|
514
|
+
fail-fast: false
|
|
515
|
+
|
|
516
|
+
steps:
|
|
517
|
+
- uses: actions/checkout@v4
|
|
518
|
+
- uses: actions/setup-java@v4
|
|
519
|
+
with:
|
|
520
|
+
java-version: ${{ matrix.java }}
|
|
521
|
+
distribution: 'temurin'
|
|
522
|
+
- run: ./mvnw verify -B
|
|
523
|
+
```
|
|
524
|
+
|
|
525
|
+
## Secrets and Environment Variables
|
|
526
|
+
|
|
527
|
+
### Required Secrets
|
|
528
|
+
|
|
529
|
+
| Secret | Description |
|
|
530
|
+
|--------|-------------|
|
|
531
|
+
| `GITHUB_TOKEN` | Auto-provided by GitHub |
|
|
532
|
+
| `SONAR_TOKEN` | SonarCloud authentication |
|
|
533
|
+
| `KUBE_CONFIG_STAGING` | Kubernetes config for staging |
|
|
534
|
+
| `KUBE_CONFIG_PRODUCTION` | Kubernetes config for production |
|
|
535
|
+
| `DOCKER_USERNAME` | Docker registry username |
|
|
536
|
+
| `DOCKER_PASSWORD` | Docker registry password |
|
|
537
|
+
|
|
538
|
+
### Environment Variables
|
|
539
|
+
|
|
540
|
+
```yaml
|
|
541
|
+
env:
|
|
542
|
+
JAVA_VERSION: '21'
|
|
543
|
+
MAVEN_OPTS: '-Xmx1024m'
|
|
544
|
+
REGISTRY: ghcr.io
|
|
545
|
+
IMAGE_NAME: ${{ github.repository }}
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
## Status Badges
|
|
549
|
+
|
|
550
|
+
```markdown
|
|
551
|
+
[](https://github.com/org/repo/actions/workflows/ci.yml)
|
|
552
|
+
[](https://codecov.io/gh/org/repo)
|
|
553
|
+
[](https://sonarcloud.io/dashboard?id=org_repo)
|
|
554
|
+
```
|
|
555
|
+
|
|
556
|
+
## Best Practices
|
|
557
|
+
|
|
558
|
+
1. **Cache dependencies**: Use `actions/cache` for Maven/Gradle
|
|
559
|
+
2. **Run tests in parallel**: Use matrix builds
|
|
560
|
+
3. **Fail fast**: Stop on first failure in parallel jobs
|
|
561
|
+
4. **Use environments**: Separate staging and production
|
|
562
|
+
5. **Require approvals**: For production deployments
|
|
563
|
+
6. **Security scans**: Include SAST, DAST, dependency scanning
|
|
564
|
+
7. **Artifact retention**: Clean up old artifacts
|
|
565
|
+
8. **Reusable workflows**: DRY principle for common tasks
|
|
566
|
+
9. **Branch protection**: Require CI to pass before merge
|
|
567
|
+
10. **Secrets management**: Never commit secrets, use GitHub Secrets
|