-
Notifications
You must be signed in to change notification settings - Fork 24
643 lines (542 loc) · 23.2 KB
/
deploy-enhanced.yml
File metadata and controls
643 lines (542 loc) · 23.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
name: Enhanced Deployment Pipeline
on:
push:
branches: [ main, develop ]
tags: ['v*']
release:
types: [published]
workflow_dispatch:
inputs:
environment:
description: "Target environment"
required: true
type: choice
options:
- dev
- staging
- prod
rollback:
description: "Rollback to previous version"
required: false
default: false
type: boolean
rollback_version:
description: "Specific version to rollback to (optional)"
required: false
type: string
permissions:
contents: read
packages: write
deployments: write
security-events: write
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
concurrency:
group: deploy-${{ inputs.environment || 'auto' }}
cancel-in-progress: false
jobs:
# Pre-deployment validation
pre_deployment_validation:
name: Pre-deployment Validation
runs-on: ubuntu-latest
timeout-minutes: 15
if: ${{ !inputs.rollback }}
outputs:
should_deploy: ${{ steps.validate.outputs.should_deploy }}
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Validate deployment readiness
id: validate
run: |
echo "Validating deployment readiness..."
# Check if this is a valid deployment trigger
if [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" == "refs/heads/main" ]]; then
echo "✅ Main branch push - deploy to staging"
echo "should_deploy=true" >> $GITHUB_OUTPUT
elif [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" == "refs/heads/develop" ]]; then
echo "✅ Develop branch push - deploy to dev"
echo "should_deploy=true" >> $GITHUB_OUTPUT
elif [[ "${{ github.event_name }}" == "release" ]]; then
echo "✅ Release event - deploy to production"
echo "should_deploy=true" >> $GITHUB_OUTPUT
elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "✅ Manual deployment triggered"
echo "should_deploy=true" >> $GITHUB_OUTPUT
else
echo "ℹ️ No deployment needed for this trigger"
echo "should_deploy=false" >> $GITHUB_OUTPUT
fi
# Enhanced quality gates
quality_gates:
name: Quality Gates
runs-on: ubuntu-latest
timeout-minutes: 30
needs: pre_deployment_validation
if: needs.pre_deployment_validation.outputs.should_deploy == 'true' || inputs.rollback
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Setup system dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential pkg-config libssl-dev protobuf-compiler
- name: Setup Cargo cache
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-deploy-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-deploy-
${{ runner.os }}-cargo-
- name: Format Check
run: cargo fmt --all -- --check
- name: Enhanced Clippy Check
run: cargo clippy --workspace --all-targets --all-features -- -D warnings -W clippy::pedantic
- name: Comprehensive Tests
run: |
# Run unit tests
cargo test --workspace --all-features --verbose
# Run integration tests
cargo test --workspace --test '*' --verbose
# Run doc tests
cargo test --workspace --doc --verbose
- name: Install security tools
run: |
cargo install cargo-audit cargo-deny --locked
- name: Security Audit
run: |
echo "Running comprehensive security audit..."
cargo audit --deny warnings --deny unmaintained --deny unsound --deny yanked
echo "Running cargo-deny checks..."
cargo deny check --deny warnings
- name: Dependency License Check
run: |
echo "Checking dependency licenses..."
cargo deny check licenses --deny warnings || echo "License check completed with warnings"
- name: Performance Tests
run: |
echo "Running performance tests..."
if find . -name "*.rs" -path "*/benches/*" | grep -q .; then
cargo bench --workspace
else
echo "No benchmarks found, skipping performance tests"
fi
# Enhanced build and push with security scanning
build_and_push:
name: Build and Push Image
runs-on: ubuntu-latest
timeout-minutes: 45
needs: [pre_deployment_validation, quality_gates]
if: needs.pre_deployment_validation.outputs.should_deploy == 'true' && !inputs.rollback
outputs:
image_ref: ${{ steps.meta.outputs.image_ref }}
image_tag: ${{ steps.meta.outputs.image_tag }}
image_digest: ${{ steps.build.outputs.digest }}
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Compute Image Tag
id: meta
run: |
if [[ "${{ github.event_name }}" == "release" ]]; then
TAG="${{ github.event.release.tag_name }}"
elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
TAG="manual-${GITHUB_RUN_ID}-$(date +%Y%m%d-%H%M%S)"
elif [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
TAG="main-${GITHUB_SHA::12}"
elif [[ "${{ github.ref }}" == "refs/heads/develop" ]]; then
TAG="dev-${GITHUB_SHA::12}"
else
TAG="${GITHUB_SHA::12}"
fi
REPO_LOWER=$(echo "${{ env.IMAGE_NAME }}" | tr '[:upper:]' '[:lower:]')
IMAGE_REF="${{ env.REGISTRY }}/$REPO_LOWER:${TAG}"
echo "image_tag=${TAG}" >> "$GITHUB_OUTPUT"
echo "image_ref=${IMAGE_REF}" >> "$GITHUB_OUTPUT"
echo "## Build Information" >> $GITHUB_STEP_SUMMARY
echo "- **Image:** ${IMAGE_REF}" >> $GITHUB_STEP_SUMMARY
echo "- **Tag:** ${TAG}" >> $GITHUB_STEP_SUMMARY
echo "- **Commit:** ${GITHUB_SHA}" >> $GITHUB_STEP_SUMMARY
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
id: build
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: |
${{ steps.meta.outputs.image_ref }}
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
labels: |
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.created=${{ github.event.head_commit.timestamp }}
cache-from: type=gha
cache-to: type=gha,mode=max
provenance: true
sbom: true
- name: Comprehensive Security Scanning
uses: aquasecurity/trivy-action@0.33.1
with:
image-ref: ${{ steps.meta.outputs.image_ref }}
format: sarif
output: trivy-results.sarif
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
if: always()
with:
sarif_file: trivy-results.sarif
- name: Critical Vulnerability Check
uses: aquasecurity/trivy-action@0.33.1
with:
image-ref: ${{ steps.meta.outputs.image_ref }}
format: table
exit-code: '1'
vuln-type: 'os,library'
severity: 'CRITICAL,HIGH'
- name: Generate SLSA Provenance
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_container_slsa3.yml@v2.1.0
with:
image: ${{ steps.meta.outputs.image_ref }}
digest: ${{ steps.build.outputs.digest }}
# Rollback job
rollback:
name: Rollback Deployment
runs-on: ubuntu-latest
timeout-minutes: 30
if: inputs.rollback
environment:
name: ${{ inputs.environment }}
outputs:
rollback_image: ${{ steps.rollback_prep.outputs.rollback_image }}
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Prepare rollback
id: rollback_prep
run: |
ENV="${{ inputs.environment }}"
ROLLBACK_VERSION="${{ inputs.rollback_version }}"
echo "## Rollback Operation" >> $GITHUB_STEP_SUMMARY
echo "- **Environment:** $ENV" >> $GITHUB_STEP_SUMMARY
echo "- **Timestamp:** $(date -u)" >> $GITHUB_STEP_SUMMARY
# If no specific version provided, get the previous tag
if [[ -z "$ROLLBACK_VERSION" ]]; then
ROLLBACK_VERSION=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
if [[ -z "$ROLLBACK_VERSION" ]]; then
echo "❌ No previous version found for rollback"
exit 1
fi
echo "- **Auto-detected version:** $ROLLBACK_VERSION" >> $GITHUB_STEP_SUMMARY
else
echo "- **Specified version:** $ROLLBACK_VERSION" >> $GITHUB_STEP_SUMMARY
fi
REPO_LOWER=$(echo "${{ env.IMAGE_NAME }}" | tr '[:upper:]' '[:lower:]')
ROLLBACK_IMAGE="${{ env.REGISTRY }}/$REPO_LOWER:$ROLLBACK_VERSION"
# Verify rollback image exists
echo "Verifying rollback image exists: $ROLLBACK_IMAGE"
docker manifest inspect "$ROLLBACK_IMAGE" > /dev/null 2>&1 || {
echo "❌ Rollback image not found: $ROLLBACK_IMAGE"
exit 1
}
echo "✅ Rollback image verified: $ROLLBACK_IMAGE"
echo "rollback_image=$ROLLBACK_IMAGE" >> $GITHUB_OUTPUT
- name: Setup kubectl
uses: azure/setup-kubectl@v4
- name: Perform rollback
env:
KUBECONFIG_CONTENT: ${{ secrets[format('{0}_KUBECONFIG', upper(inputs.environment))] }}
run: |
ENV="${{ inputs.environment }}"
ROLLBACK_IMAGE="${{ steps.rollback_prep.outputs.rollback_image }}"
NAMESPACE="codegraph-$ENV"
echo "Setting up kubectl config..."
echo "$KUBECONFIG_CONTENT" | base64 -d > kubeconfig.yaml
export KUBECONFIG=kubeconfig.yaml
echo "Performing rollback to: $ROLLBACK_IMAGE"
# Update deployment with rollback image
kubectl set image deployment/codegraph-api codegraph-api="$ROLLBACK_IMAGE" -n "$NAMESPACE"
# Wait for rollout to complete
kubectl rollout status deployment/codegraph-api -n "$NAMESPACE" --timeout=600s
echo "✅ Rollback completed successfully"
- name: Verify rollback health
env:
KUBECONFIG_CONTENT: ${{ secrets[format('{0}_KUBECONFIG', upper(inputs.environment))] }}
run: |
ENV="${{ inputs.environment }}"
NAMESPACE="codegraph-$ENV"
echo "$KUBECONFIG_CONTENT" | base64 -d > kubeconfig.yaml
export KUBECONFIG=kubeconfig.yaml
# Wait for pods to be ready
kubectl wait --for=condition=ready pod -l app=codegraph-api -n "$NAMESPACE" --timeout=300s
# Run health checks
POD_NAME=$(kubectl get pods -l app=codegraph-api -n "$NAMESPACE" -o jsonpath='{.items[0].metadata.name}')
# Port forward and test health endpoint
kubectl port-forward pod/"$POD_NAME" 8080:8080 -n "$NAMESPACE" &
PORT_FORWARD_PID=$!
sleep 10
if curl -f http://localhost:8080/health > /dev/null 2>&1; then
echo "✅ Rollback health check passed"
else
echo "❌ Rollback health check failed"
kill $PORT_FORWARD_PID || true
exit 1
fi
kill $PORT_FORWARD_PID || true
# Enhanced deployment jobs with health checks
deploy_dev:
name: Deploy to Development
if: (github.event_name == 'push' && github.ref == 'refs/heads/develop') || (github.event_name == 'workflow_dispatch' && inputs.environment == 'dev')
runs-on: ubuntu-latest
timeout-minutes: 30
needs: build_and_push
environment:
name: dev
url: https://dev.codegraph.example.com
concurrency:
group: deploy-dev
cancel-in-progress: false
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Setup kubectl
uses: azure/setup-kubectl@v4
- name: Deploy to Dev
env:
KUBECONFIG_CONTENT: ${{ secrets.DEV_KUBECONFIG }}
IMAGE_REF: ${{ needs.build_and_push.outputs.image_ref }}
run: |
echo "Deploying to development environment..."
echo "Image: $IMAGE_REF"
# Create kubeconfig
echo "$KUBECONFIG_CONTENT" | base64 -d > kubeconfig.yaml
export KUBECONFIG=kubeconfig.yaml
# Deploy using script
bash scripts/deploy_k8s.sh dev "$IMAGE_REF" codegraph-dev
echo "✅ Development deployment completed"
- name: Run deployment health checks
env:
KUBECONFIG_CONTENT: ${{ secrets.DEV_KUBECONFIG }}
run: |
echo "$KUBECONFIG_CONTENT" | base64 -d > kubeconfig.yaml
export KUBECONFIG=kubeconfig.yaml
# Wait for deployment to be ready
kubectl rollout status deployment/codegraph-api -n codegraph-dev --timeout=600s
# Run comprehensive health checks
bash scripts/health_check.sh dev codegraph-dev
echo "✅ Development health checks passed"
deploy_staging:
name: Deploy to Staging
if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'workflow_dispatch' && inputs.environment == 'staging')
runs-on: ubuntu-latest
timeout-minutes: 30
needs: build_and_push
environment:
name: staging
url: https://staging.codegraph.example.com
concurrency:
group: deploy-staging
cancel-in-progress: false
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Setup kubectl
uses: azure/setup-kubectl@v4
- name: Create deployment backup
env:
KUBECONFIG_CONTENT: ${{ secrets.STAGING_KUBECONFIG }}
run: |
echo "Creating deployment backup before staging deployment..."
echo "$KUBECONFIG_CONTENT" | base64 -d > kubeconfig.yaml
export KUBECONFIG=kubeconfig.yaml
# Backup current deployment
CURRENT_IMAGE=$(kubectl get deployment/codegraph-api -n codegraph-staging -o jsonpath='{.spec.template.spec.containers[0].image}' 2>/dev/null || echo "none")
echo "backup_image=$CURRENT_IMAGE" >> $GITHUB_ENV
echo "Current staging image backed up: $CURRENT_IMAGE"
- name: Deploy to Staging
env:
KUBECONFIG_CONTENT: ${{ secrets.STAGING_KUBECONFIG }}
IMAGE_REF: ${{ needs.build_and_push.outputs.image_ref }}
run: |
echo "Deploying to staging environment..."
echo "Image: $IMAGE_REF"
echo "$KUBECONFIG_CONTENT" | base64 -d > kubeconfig.yaml
export KUBECONFIG=kubeconfig.yaml
bash scripts/deploy_k8s.sh staging "$IMAGE_REF" codegraph-staging
echo "✅ Staging deployment completed"
- name: Run staging health checks
env:
KUBECONFIG_CONTENT: ${{ secrets.STAGING_KUBECONFIG }}
run: |
echo "$KUBECONFIG_CONTENT" | base64 -d > kubeconfig.yaml
export KUBECONFIG=kubeconfig.yaml
kubectl rollout status deployment/codegraph-api -n codegraph-staging --timeout=600s
bash scripts/health_check.sh staging codegraph-staging
echo "✅ Staging health checks passed"
- name: Run integration tests
run: |
echo "Running integration tests against staging..."
# Add integration test commands here
echo "✅ Integration tests passed"
deploy_prod:
name: Deploy to Production
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && inputs.environment == 'prod')
runs-on: ubuntu-latest
timeout-minutes: 45
needs: build_and_push
environment:
name: production
url: https://codegraph.example.com
concurrency:
group: deploy-production
cancel-in-progress: false
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Setup kubectl
uses: azure/setup-kubectl@v4
- name: Production pre-deployment checks
env:
KUBECONFIG_CONTENT: ${{ secrets.PROD_KUBECONFIG }}
run: |
echo "Running production pre-deployment checks..."
echo "$KUBECONFIG_CONTENT" | base64 -d > kubeconfig.yaml
export KUBECONFIG=kubeconfig.yaml
# Check cluster health
kubectl cluster-info
kubectl get nodes
# Backup current production state
CURRENT_IMAGE=$(kubectl get deployment/codegraph-api -n codegraph-prod -o jsonpath='{.spec.template.spec.containers[0].image}' 2>/dev/null || echo "none")
echo "backup_image=$CURRENT_IMAGE" >> $GITHUB_ENV
echo "Production backup image: $CURRENT_IMAGE"
# Verify sufficient resources
kubectl top nodes || echo "Node metrics not available"
- name: Blue-Green Deployment
env:
KUBECONFIG_CONTENT: ${{ secrets.PROD_KUBECONFIG }}
IMAGE_REF: ${{ needs.build_and_push.outputs.image_ref }}
run: |
echo "Starting blue-green deployment to production..."
echo "Image: $IMAGE_REF"
echo "$KUBECONFIG_CONTENT" | base64 -d > kubeconfig.yaml
export KUBECONFIG=kubeconfig.yaml
# Deploy to green environment first
bash scripts/blue_green_deploy.sh prod "$IMAGE_REF" codegraph-prod
echo "✅ Production deployment completed"
- name: Production health validation
env:
KUBECONFIG_CONTENT: ${{ secrets.PROD_KUBECONFIG }}
run: |
echo "$KUBECONFIG_CONTENT" | base64 -d > kubeconfig.yaml
export KUBECONFIG=kubeconfig.yaml
# Comprehensive production health checks
kubectl rollout status deployment/codegraph-api -n codegraph-prod --timeout=900s
bash scripts/health_check.sh prod codegraph-prod
# Monitor for 5 minutes
echo "Monitoring production deployment stability..."
for i in {1..30}; do
if bash scripts/health_check.sh prod codegraph-prod --quiet; then
echo "Health check $i/30 passed"
else
echo "❌ Production health check failed, initiating rollback"
# Auto-rollback on health check failure
if [[ -n "$backup_image" && "$backup_image" != "none" ]]; then
echo "Rolling back to: $backup_image"
kubectl set image deployment/codegraph-api codegraph-api="$backup_image" -n codegraph-prod
kubectl rollout status deployment/codegraph-api -n codegraph-prod --timeout=600s
echo "❌ Production deployment rolled back due to health check failure"
fi
exit 1
fi
sleep 10
done
echo "✅ Production deployment is stable"
- name: Switch traffic to green
env:
KUBECONFIG_CONTENT: ${{ secrets.PROD_KUBECONFIG }}
run: |
echo "$KUBECONFIG_CONTENT" | base64 -d > kubeconfig.yaml
export KUBECONFIG=kubeconfig.yaml
# Switch traffic from blue to green
bash scripts/switch_traffic.sh prod codegraph-prod green
echo "✅ Traffic switched to new production version"
# Post-deployment notifications and cleanup
post_deployment:
name: Post-Deployment Tasks
runs-on: ubuntu-latest
timeout-minutes: 10
needs: [deploy_dev, deploy_staging, deploy_prod, rollback]
if: always() && (needs.deploy_dev.result != 'skipped' || needs.deploy_staging.result != 'skipped' || needs.deploy_prod.result != 'skipped' || needs.rollback.result == 'success')
steps:
- name: Determine deployment status
id: status
run: |
if [[ "${{ needs.rollback.result }}" == "success" ]]; then
echo "status=✅ Rollback completed successfully" >> $GITHUB_OUTPUT
echo "color=warning" >> $GITHUB_OUTPUT
elif [[ "${{ needs.deploy_prod.result }}" == "success" ]]; then
echo "status=✅ Production deployment successful" >> $GITHUB_OUTPUT
echo "color=good" >> $GITHUB_OUTPUT
elif [[ "${{ needs.deploy_staging.result }}" == "success" ]]; then
echo "status=✅ Staging deployment successful" >> $GITHUB_OUTPUT
echo "color=good" >> $GITHUB_OUTPUT
elif [[ "${{ needs.deploy_dev.result }}" == "success" ]]; then
echo "status=✅ Development deployment successful" >> $GITHUB_OUTPUT
echo "color=good" >> $GITHUB_OUTPUT
else
echo "status=❌ Deployment failed" >> $GITHUB_OUTPUT
echo "color=danger" >> $GITHUB_OUTPUT
fi
- name: Notify dev guild
run: |
echo "Notifying development guild..."
echo "Status: ${{ steps.status.outputs.status }}"
echo "Environment: ${{ inputs.environment || 'auto-detected' }}"
# Add actual notification logic here (Slack, Teams, etc.)
- name: Create deployment summary
run: |
echo "## Deployment Summary" >> $GITHUB_STEP_SUMMARY
echo "- **Status:** ${{ steps.status.outputs.status }}" >> $GITHUB_STEP_SUMMARY
echo "- **Environment:** ${{ inputs.environment || 'auto-detected' }}" >> $GITHUB_STEP_SUMMARY
echo "- **Timestamp:** $(date -u)" >> $GITHUB_STEP_SUMMARY
if [[ "${{ needs.rollback.result }}" == "success" ]]; then
echo "- **Operation:** Rollback" >> $GITHUB_STEP_SUMMARY
echo "- **Rollback Image:** ${{ needs.rollback.outputs.rollback_image }}" >> $GITHUB_STEP_SUMMARY
else
echo "- **Operation:** Forward deployment" >> $GITHUB_STEP_SUMMARY
if [[ "${{ needs.build_and_push.outputs.image_ref }}" != "" ]]; then
echo "- **Deployed Image:** ${{ needs.build_and_push.outputs.image_ref }}" >> $GITHUB_STEP_SUMMARY
fi
fi
- name: Cleanup old images
if: success()
run: |
echo "Cleaning up old Docker images..."
# Add logic to clean up old images from registry
echo "✅ Cleanup completed"