This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 "=========================================" |