-
Notifications
You must be signed in to change notification settings - Fork 0
699 lines (599 loc) ยท 25.5 KB
/
demo-az-pipeline.yml
File metadata and controls
699 lines (599 loc) ยท 25.5 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
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
name: Demo - Azure Infrastructure Deployment Pipeline
on:
push:
branches: [ main, develop, demo ]
pull_request:
branches: [ main ]
workflow_dispatch:
inputs:
environment:
description: 'Target Environment'
required: true
default: 'development'
type: choice
options:
- development
- staging
- production
simulate_failure:
description: 'Simulate a failure (for demo purposes)'
required: false
default: 'none'
type: choice
options:
- none
- jira
- change_request
- terraform
- post_deploy
jobs:
check-jira:
name: ๐ซ Check Jira
runs-on: ubuntu-latest
outputs:
jira_issue_id: ${{ steps.get-issue.outputs.issue_id }}
finops_story_id: ${{ steps.get-finops-story.outputs.story_id }}
finops_tags: ${{ steps.get-finops-tags.outputs.tags }}
steps:
- name: ๐ฅ Checkout code
uses: actions/checkout@v4
- name: ๐ Simulate Jira API Failure
if: inputs.simulate_failure == 'jira'
run: |
echo "โ Simulating Jira API connection failure..."
exit 1
- name: ๐ฏ Get FinOpsStory Details
id: get-issue
run: |
echo "๐ Extracting Jira issue from commit message..."
sleep 2
# Simulate extracting issue from commit
ISSUE_KEY="FINOPS-$(shuf -i 100-999 -n 1)"
echo "issue_id=${ISSUE_KEY}" >> $GITHUB_OUTPUT
echo "โ
Found Jira Issue: ${ISSUE_KEY}"
- name: ๐ท๏ธ Get Child FinOps Tag Story ID
id: get-finops-story
run: |
echo "๐ Querying Jira for child FinOps stories..."
sleep 2
# Simulate finding child story
PARENT="${{ steps.get-issue.outputs.issue_id }}"
CHILD_STORY="${PARENT}-FINOPS"
echo "story_id=${CHILD_STORY}" >> $GITHUB_OUTPUT
echo "โ
Found FinOps Story: ${CHILD_STORY}"
- name: ๐ Get ChildStory Details
run: |
echo "๐ Fetching detailed story information from Jira..."
echo " - Story Points: 5"
echo " - Sprint: Infrastructure Q1"
echo " - Assignee: Platform Team"
sleep 1
- name: ๐ท๏ธ Get FinOps Tags
id: get-finops-tags
run: |
echo "๐ท๏ธ Extracting FinOps tags from Jira custom fields..."
sleep 2
# Simulate tag extraction
TAGS_JSON=$(jq -n \
--arg env "${{ inputs.environment || 'development' }}" \
'{
"CostCenter": "IT-001",
"ProjectCode": "FINOPS-2024",
"Department": "Platform-Engineering",
"Environment": $env,
"Owner": "platform-team@company.com",
"Purpose": "Demo-Pipeline"
}')
# Use delimiter to handle multiline output safely
echo "tags<<EOF" >> $GITHUB_OUTPUT
echo "$TAGS_JSON" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
echo "โ
FinOps Tags collected:"
echo "$TAGS_JSON" | jq .
- name: ๐ข Check IIC Project Status
id: check-iic
run: |
echo "๐ Checking if this is an IIC project..."
# Simulate IIC project detection (check commit message or project code)
COMMIT_MSG="${{ github.event.head_commit.message || 'demo commit' }}"
if [[ "$COMMIT_MSG" == *"IIC"* ]] || [[ "${{ needs.check-jira.outputs.jira_issue_id }}" == *"IIC"* ]]; then
echo "is_iic=true" >> $GITHUB_OUTPUT
echo "โ
IIC project detected"
else
echo "is_iic=false" >> $GITHUB_OUTPUT
echo "โน๏ธ Not an IIC project"
fi
- name: ๐ข Get Additional IIC Tags
if: steps.check-iic.outputs.is_iic == 'true'
run: |
echo "๐ท๏ธ Adding IIC-specific tags..."
echo " ๐ Compliance Level: High"
echo " ๐ Security Classification: Restricted"
echo " ๐ Audit Required: Yes"
echo "โ
IIC tags configured"
release-variables-setup:
name: ๐ง Release Variables Setup
runs-on: ubuntu-latest
needs: check-jira
outputs:
resource_group_name: ${{ steps.generate-names.outputs.resource_group_name }}
naming_prefix: ${{ steps.generate-names.outputs.naming_prefix }}
vm_names: ${{ steps.generate-vm-names.outputs.vm_names }}
timestamp: ${{ steps.generate-names.outputs.timestamp }}
steps:
- name: ๐ท๏ธ Generate Azure Names
id: generate-names
run: |
echo "๐ฏ Generating standardized Azure resource names..."
# Generate demo names
TIMESTAMP=$(date +%Y%m%d%H%M%S)
ENV_SHORT="${{ inputs.environment || 'dev' }}"
ENV_SHORT=${ENV_SHORT:0:3}
NAMING_PREFIX="demo-${ENV_SHORT}-${TIMESTAMP:0:8}"
RG_NAME="rg-${NAMING_PREFIX}"
echo "resource_group_name=${RG_NAME}" >> $GITHUB_OUTPUT
echo "naming_prefix=${NAMING_PREFIX}" >> $GITHUB_OUTPUT
echo "timestamp=${TIMESTAMP}" >> $GITHUB_OUTPUT
echo "โ
Generated naming convention:"
echo " ๐ Resource Group: ${RG_NAME}"
echo " ๐ท๏ธ Naming Prefix: ${NAMING_PREFIX}"
sleep 1
- name: ๐ฅ๏ธ Generate Bastion VM Name
id: generate-bastion
run: |
PREFIX="${{ steps.generate-names.outputs.naming_prefix }}"
BASTION_NAME="vm-bastion-${PREFIX}"
echo "bastion_name=${BASTION_NAME}" >> $GITHUB_OUTPUT
echo "โ
Bastion VM: ${BASTION_NAME}"
- name: ๐ Generate Web VM Name(s)
id: generate-web
run: |
echo "๐ฅ๏ธ Generating Web VM names..."
PREFIX="${{ steps.generate-names.outputs.naming_prefix }}"
WEB_NAMES=()
for i in {1..3}; do
NAME="vm-web-${PREFIX}-${i}"
WEB_NAMES+=("${NAME}")
echo " โ ${NAME}"
done
WEB_JSON=$(printf '%s\n' "${WEB_NAMES[@]}" | jq -R . | jq -s .)
echo "web_names<<EOF" >> $GITHUB_OUTPUT
echo "$WEB_JSON" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: ๐ฑ Generate App VM Name(s)
id: generate-app
run: |
echo "๐ฅ๏ธ Generating App VM names..."
PREFIX="${{ steps.generate-names.outputs.naming_prefix }}"
APP_NAMES=()
for i in {1..2}; do
NAME="vm-app-${PREFIX}-${i}"
APP_NAMES+=("${NAME}")
echo " โ ${NAME}"
done
APP_JSON=$(printf '%s\n' "${APP_NAMES[@]}" | jq -R . | jq -s .)
echo "app_names<<EOF" >> $GITHUB_OUTPUT
echo "$APP_JSON" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: ๐๏ธ Generate DB VM Name(s) - Windows
id: generate-db-win
run: |
PREFIX="${{ steps.generate-names.outputs.naming_prefix }}"
DB_WIN_NAME="vm-db-win-${PREFIX}"
echo "db_win_name=${DB_WIN_NAME}" >> $GITHUB_OUTPUT
echo "โ
Windows DB VM: ${DB_WIN_NAME}"
- name: ๐ง Generate DB VM Name(s) - Linux
id: generate-db-linux
run: |
PREFIX="${{ steps.generate-names.outputs.naming_prefix }}"
DB_LINUX_NAME="vm-db-linux-${PREFIX}"
echo "db_linux_name=${DB_LINUX_NAME}" >> $GITHUB_OUTPUT
echo "โ
Linux DB VM: ${DB_LINUX_NAME}"
- name: ๐ Add Credentials (Compile VM Names)
id: generate-vm-names
run: |
echo "๐ Compiling all VM names..."
# Create a simple JSON structure without complex jq operations
cat > vm-inventory.json << EOF
{
"bastion": "${{ steps.generate-bastion.outputs.bastion_name }}",
"web": [
"vm-web-${{ steps.generate-names.outputs.naming_prefix }}-1",
"vm-web-${{ steps.generate-names.outputs.naming_prefix }}-2",
"vm-web-${{ steps.generate-names.outputs.naming_prefix }}-3"
],
"app": [
"vm-app-${{ steps.generate-names.outputs.naming_prefix }}-1",
"vm-app-${{ steps.generate-names.outputs.naming_prefix }}-2"
],
"db_windows": "${{ steps.generate-db-win.outputs.db_win_name }}",
"db_linux": "${{ steps.generate-db-linux.outputs.db_linux_name }}"
}
EOF
VM_NAMES=$(cat vm-inventory.json)
# Use delimiter for multiline JSON output
echo "vm_names<<EOF" >> $GITHUB_OUTPUT
echo "$VM_NAMES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
echo "โ
VM inventory compiled successfully"
sleep 1
standard-charge-creation:
name: ๐ Standard Charge Creation
runs-on: ubuntu-latest
needs: [check-jira, release-variables-setup]
outputs:
change_request_id: ${{ steps.create-cr.outputs.cr_number }}
steps:
- name: ๐ Create and Start Standard CR
id: create-cr
run: |
echo "๐ Creating Standard Change Request in ServiceNow..."
echo " ๐ Type: Standard"
echo " ๐ Category: Infrastructure"
echo " ๐ฏ Risk: Low"
sleep 3
# Generate demo CR number
CR_NUMBER="CR-$(date +%Y%m%d)-$(shuf -i 1000-9999 -n 1)"
echo "โ
Created Change Request: ${CR_NUMBER}"
echo " ๐ Status: Draft"
echo " ๐ค Assigned to: CAB Team"
echo " ๐
Implementation Window: Next 2 hours"
echo "cr_number=${CR_NUMBER}" >> $GITHUB_OUTPUT
- name: โณ Wait for CR to Start
run: |
echo "โณ Waiting for Change Request approval..."
echo " ๐ Polling ServiceNow API..."
# Simulate approval process
for i in {1..5}; do
echo " โฑ๏ธ Checking approval status... (${i}/5)"
sleep 2
done
if [[ "${{ inputs.simulate_failure }}" == "change_request" ]]; then
echo "โ Change Request rejected by CAB"
exit 1
fi
echo "โ
Change Request approved!"
echo " โ Approved by: CAB-AUTO"
echo " โ Implementation can proceed"
build-azure-vms:
name: ๐ฅ๏ธ Deploy Azure VMs
runs-on: ubuntu-latest
needs: [check-jira, release-variables-setup, standard-charge-creation]
steps:
- name: ๐ฅ Checkout code
uses: actions/checkout@v4
- name: ๐ง Setup Terraform
run: |
echo "๐ฆ Installing Terraform v1.5.0..."
echo "โ
Terraform installed successfully"
- name: ๐ Azure Login
run: |
echo "๐ Authenticating with Azure..."
echo " ๐ Using Service Principal"
echo " ๐ Subscription: Demo-Subscription"
echo "โ
Successfully authenticated to Azure"
sleep 1
- name: ๐ Terraform Init
run: |
echo "๐ Initializing Terraform..."
echo " ๐ Working directory: ./terraform"
echo " ๐ช Backend: Azure Storage Account"
sleep 2
echo "โ
Terraform initialized successfully"
- name: ๐ Terraform Validate
run: |
echo "๐ Validating Terraform configuration..."
echo " ๐ Checking syntax and structure"
echo " ๐ง Validating provider configurations"
sleep 2
echo "โ
Terraform configuration is valid"
- name: ๐ Terraform Plan
run: |
echo "๐ Creating Terraform execution plan..."
echo " ๐ฏ Target Environment: ${{ inputs.environment || 'development' }}"
echo " ๐ Analyzing current state vs desired state"
sleep 3
echo ""
echo "๐ Plan Summary:"
echo " โ 25 resources to add"
echo " ๐ 0 resources to change"
echo " โ 0 resources to destroy"
echo ""
echo "โ
Terraform plan completed successfully"
- name: ๐ Terraform Apply - Deploy Azure Resources
run: |
echo "๐ Starting Terraform Apply..."
echo ""
echo "๐ Deployment Configuration:"
echo " ๐ Resource Group: ${{ needs.release-variables-setup.outputs.resource_group_name }}"
echo " ๐ Region: East US"
echo " ๐ท๏ธ Tags: ${{ needs.check-jira.outputs.finops_tags }}"
echo ""
if [[ "${{ inputs.simulate_failure }}" == "terraform" ]]; then
echo "โ Terraform apply failed!"
echo "Error: Error creating Virtual Machine: Code=\"OperationNotAllowed\""
exit 1
fi
echo "๐๏ธ Executing Terraform apply..."
echo ""
# Step 1: Create Resource Group
echo "๐ Creating Resource Group..."
echo " โ azurerm_resource_group.main"
sleep 1
# Step 2: Create Virtual Network & Subnets
echo ""
echo "๐ Creating Virtual Network & Subnets..."
echo " โ azurerm_virtual_network.main (10.0.0.0/16)"
echo " โ azurerm_subnet.bastion (10.0.1.0/24)"
echo " โ azurerm_subnet.web (10.0.2.0/24)"
echo " โ azurerm_subnet.app (10.0.3.0/24)"
echo " โ azurerm_subnet.db (10.0.4.0/24)"
sleep 2
# Step 3: Create Network Security Groups
echo ""
echo "๐ Creating Network Security Groups & Rules..."
echo " โ azurerm_network_security_group.bastion (SSH: 22)"
echo " โ azurerm_network_security_group.web (HTTP: 80, HTTPS: 443)"
echo " โ azurerm_network_security_group.app (Internal: 8080)"
echo " โ azurerm_network_security_group.db (SQL: 1433, MySQL: 3306)"
sleep 2
# Step 4: Create Bastion Host
echo ""
echo "๐ฐ Creating Bastion Host..."
echo " โ azurerm_public_ip.bastion"
echo " โ azurerm_network_interface.bastion"
echo " โ azurerm_linux_virtual_machine.bastion (Standard_B2s)"
sleep 1
# Step 5: Create Web Tier VMs
echo ""
echo "๐ Creating Web Tier (3 VMs)..."
echo " โ azurerm_availability_set.web"
echo " โ azurerm_linux_virtual_machine.web[0] (Standard_B2s)"
echo " โ azurerm_linux_virtual_machine.web[1] (Standard_B2s)"
echo " โ azurerm_linux_virtual_machine.web[2] (Standard_B2s)"
sleep 2
# Step 6: Create App Tier VMs
echo ""
echo "๐ฑ Creating App Tier (2 VMs)..."
echo " โ azurerm_availability_set.app"
echo " โ azurerm_linux_virtual_machine.app[0] (Standard_B4ms)"
echo " โ azurerm_linux_virtual_machine.app[1] (Standard_B4ms)"
sleep 1
# Step 7: Create Database VMs
echo ""
echo "๐พ Creating Database Tier (2 VMs)..."
echo " โ azurerm_windows_virtual_machine.db_windows (Standard_D4s_v3)"
echo " โ azurerm_linux_virtual_machine.db_linux (Standard_D4s_v3)"
sleep 1
# Step 8: Create Key Vault
echo ""
echo "๐ Creating Key Vault & Secrets..."
echo " โ azurerm_key_vault.main"
echo " โ azurerm_key_vault_secret.ssh_key"
echo " โ azurerm_key_vault_secret.admin_password"
sleep 1
# Step 9: Apply FinOps Tags
echo ""
echo "๐ท๏ธ Applying FinOps Tags to All Resources..."
echo " โ CostCenter: IT-001"
echo " โ ProjectCode: FINOPS-2024"
echo " โ Department: Platform-Engineering"
echo " โ Environment: ${{ inputs.environment || 'development' }}"
echo " โ Owner: platform-team@company.com"
echo " โ Purpose: Demo-Pipeline"
sleep 2
echo ""
echo "โ
All Azure Resources deployed successfully!"
echo ""
echo "๐ Infrastructure Deployment Summary:"
echo " โ 1 Resource Group"
echo " โ 1 Virtual Network with 4 Subnets"
echo " โ 4 Network Security Groups"
echo " โ 1 Bastion Host (Public IP: 20.42.$(shuf -i 1-255 -n 1).$(shuf -i 1-255 -n 1))"
echo " โ 3 Web Servers (Load Balanced)"
echo " โ 2 App Servers (High Availability)"
echo " โ 2 Database Servers (Windows + Linux)"
echo " โ 1 Key Vault (Credentials Secured)"
echo " โ All resources tagged for FinOps compliance"
- name: ๐ Generate Deployment Report
if: always()
run: |
echo "๐ Generating deployment report..."
cat > deployment-report.md << EOF
# ๐ Deployment Report
## Summary
- **Date**: $(date)
- **Pipeline Run**: #${{ github.run_number }}
- **Triggered By**: ${{ github.actor }}
- **Environment**: ${{ inputs.environment || 'development' }}
## Change Management
- **Jira Issue**: ${{ needs.check-jira.outputs.jira_issue_id }}
- **Change Request**: ${{ needs.standard-charge-creation.outputs.change_request_id }}
- **FinOps Story**: ${{ needs.check-jira.outputs.finops_story_id }}
## Infrastructure Deployed
- **Resource Group**: ${{ needs.release-variables-setup.outputs.resource_group_name }}
- **Region**: East US
- **Virtual Machines**: 8 total (1 Bastion, 3 Web, 2 App, 2 DB)
- **Deployment Status**: ${{ job.status }}
## Cost Estimation
- **Monthly Estimate**: \$2,450
- **Daily Estimate**: \$82
## Next Steps
1. Verify application deployment
2. Configure monitoring alerts
3. Update DNS records
4. Schedule penetration testing
EOF
echo "โ
Report generated: deployment-report.md"
- name: ๐ค Upload Deployment Report
if: always()
uses: actions/upload-artifact@v4
with:
name: deployment-report-azure-vms
path: deployment-report.md
build-sql-databases:
name: ๐พ Install SQL Databases
runs-on: ubuntu-latest
needs: [check-jira, release-variables-setup, standard-charge-creation]
steps:
- name: ๐พ Install SQL DB on Azure VMs
run: |
echo "๐พ Installing SQL Database on Azure VMs..."
echo ""
echo "๐ช Windows SQL Server:"
echo " โน๏ธ SQL Server 2022 pre-installed with image"
echo " โ Configuring SQL Server settings..."
sleep 2
echo " โ Creating demo database..."
sleep 1
echo " โ Setting up backup schedule..."
sleep 1
echo " โ
Windows SQL Server ready!"
echo ""
echo "๐ง Linux MySQL Server:"
echo " ๐ฆ Installing MySQL Server..."
sleep 2
echo " โ MySQL 8.0 installed"
echo " โ Configuring MySQL settings..."
sleep 1
echo " โ Creating demo database..."
sleep 1
echo " โ Setting up replication..."
sleep 1
echo " โ
Linux MySQL Server ready!"
echo ""
echo "โ
All database servers configured successfully!"
- name: ๐ Generate Database Report
if: always()
run: |
echo "๐ Generating database installation report..."
cat > database-report.md << EOF
# ๐พ Database Installation Report
## Summary
- **Date**: $(date)
- **Pipeline Run**: #${{ github.run_number }}
- **Environment**: ${{ inputs.environment || 'development' }}
## Database Servers Configured
- **Windows SQL Server 2022**: Ready
- **Linux MySQL 8.0**: Ready
- **Backup Configuration**: Enabled
- **Replication Setup**: Active
## Configuration Details
- **SQL Server Port**: 1433
- **MySQL Port**: 3306
- **High Availability**: Configured
- **Security**: SSL Enabled
## Next Steps
1. Configure application connections
2. Set up monitoring dashboards
3. Schedule maintenance windows
4. Verify backup procedures
EOF
echo "โ
Database report generated"
- name: ๐ค Upload Database Report
if: always()
uses: actions/upload-artifact@v4
with:
name: deployment-report-sql-databases
path: database-report.md
post-deployment:
name: ๐ฎ Post Deployment Tasks
runs-on: ubuntu-latest
needs: [build-azure-vms, build-sql-databases, check-jira, release-variables-setup, standard-charge-creation]
if: always()
steps:
- name: ๐ซ Update Jira
run: |
echo "๐ซ Updating Jira ticket..."
echo " ๐ Issue: ${{ needs.check-jira.outputs.jira_issue_id }}"
# Check if both build jobs succeeded
VM_STATUS="${{ needs.build-azure-vms.result }}"
DB_STATUS="${{ needs.build-sql-databases.result }}"
if [[ "$VM_STATUS" == "success" && "$DB_STATUS" == "success" ]]; then
STATUS="success"
else
STATUS="failure"
fi
if [[ "$STATUS" == "success" ]]; then
echo " โ
Adding success comment to Jira"
echo " ๐ Attaching deployment report"
echo " ๐ท๏ธ Updating status: In Progress โ Done"
else
echo " โ Adding failure comment to Jira"
echo " ๐ Attaching error logs"
echo " ๐ท๏ธ Status remains: In Progress"
fi
sleep 2
echo "โ
Jira updated successfully"
- name: ๐ข Send Notifications
run: |
echo "๐ข Sending deployment notifications..."
# Check if both build jobs succeeded
VM_STATUS="${{ needs.build-azure-vms.result }}"
DB_STATUS="${{ needs.build-sql-databases.result }}"
if [[ "$VM_STATUS" == "success" && "$DB_STATUS" == "success" ]]; then
STATUS="success"
else
STATUS="failure"
fi
STATUS_EMOJI=$([ "$STATUS" == "success" ] && echo "โ
" || echo "โ")
echo ""
echo "๐ง Email Notification:"
echo " To: platform-team@company.com"
echo " Subject: ${STATUS_EMOJI} Deployment $STATUS - ${{ needs.check-jira.outputs.jira_issue_id }}"
echo ""
echo "๐ฌ Slack Notification:"
echo " Channel: #infrastructure-alerts"
echo " Message: ${STATUS_EMOJI} Azure deployment $STATUS"
echo ""
echo "๐ Microsoft Teams:"
echo " Channel: Platform Engineering"
echo " Card: Deployment Summary with interactive buttons"
if [[ "${{ inputs.simulate_failure }}" == "post_deploy" ]]; then
echo ""
echo "โ Failed to send notifications!"
exit 1
fi
sleep 2
echo ""
echo "โ
All notifications sent successfully"
- name: ๐ Close Change Request
run: |
echo "๐ Closing Change Request..."
echo " ๐ CR: ${{ needs.standard-charge-creation.outputs.change_request_id }}"
# Check if both build jobs succeeded
VM_STATUS="${{ needs.build-azure-vms.result }}"
DB_STATUS="${{ needs.build-sql-databases.result }}"
if [[ "$VM_STATUS" == "success" && "$DB_STATUS" == "success" ]]; then
STATUS="success"
else
STATUS="failure"
fi
if [[ "$STATUS" == "success" ]]; then
echo " โ
Closing as: Successful"
echo " ๐ Close notes: Deployment completed without issues"
else
echo " โ Closing as: Failed"
echo " ๐ Close notes: Deployment failed - see GitHub Actions logs"
fi
sleep 2
echo "โ
Change Request closed"
- name: ๐ Final Summary
if: always()
run: |
echo ""
echo "========================================="
echo "๐ PIPELINE EXECUTION SUMMARY"
echo "========================================="
echo ""
echo "Pipeline: ${{ needs.build.result == 'success' && 'โ
SUCCESS' || 'โ FAILED' }}"
echo ""
echo "Stages Completed:"
echo " ${{ needs.check-jira.result == 'success' && 'โ
' || 'โ' }} Jira Validation"
echo " ${{ needs.release-variables-setup.result == 'success' && 'โ
' || 'โ' }} Variable Setup"
echo " ${{ needs.standard-charge-creation.result == 'success' && 'โ
' || 'โ' }} Change Management"
echo " ${{ needs.build.result == 'success' && 'โ
' || 'โ' }} Infrastructure Build"
echo " ${{ job.status == 'success' && 'โ
' || 'โ' }} Post Deployment"
echo ""
echo "Total Duration: ~5 minutes (demo)"
echo "========================================="