@@ -13,39 +13,84 @@ permissions:
1313 id-token : write # Required for AWS OIDC authentication
1414
1515jobs :
16- generate-report :
16+ export-dashboards :
1717 runs-on : ubuntu-latest
18- environment : prod
18+ environment : reporting
19+ strategy :
20+ matrix :
21+ env_config :
22+ - name : Prod
23+ dashboard : Demand_And_Capacity_Prod
24+ account_secret : AWS_PROD_ACCOUNT_ID
25+ - name : Preprod
26+ dashboard : Demand_And_Capacity_Preprod
27+ account_secret : AWS_PREPROD_ACCOUNT_ID
28+ - name : Test
29+ dashboard : Demand_And_Capacity_Test
30+ account_secret : AWS_TEST_ACCOUNT_ID
31+ - name : Dev
32+ dashboard : Demand_And_Capacity_Dev
33+ account_secret : AWS_DEV_ACCOUNT_ID
1934
2035 steps :
2136 - name : Checkout code
22- uses : actions/checkout@v6
37+ uses : actions/checkout@v4
2338
2439 - name : Set up Python
25- uses : actions/setup-python@v6
40+ uses : actions/setup-python@v5
2641 with :
2742 python-version : " 3.11"
2843
29- - name : " Configure AWS Credentials"
44+ - name : Configure AWS Credentials (${{ matrix.env_config.name }})
3045 uses : aws-actions/configure-aws-credentials@v5
3146 with :
32- role-to-assume : arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/service-roles/github-actions-api-deployment-role
47+ role-to-assume : arn:aws:iam::${{ secrets[matrix.env_config.account_secret] }}:role/service-roles/github-actions-api-deployment-role
3348 aws-region : eu-west-2
3449
35- - name : Generate dashboard report
50+ - name : Export Dashboard (${{ matrix.env_config.name }})
3651 run : |
3752 chmod +x scripts/export_dashboard_image.sh
38- ./scripts/export_dashboard_image.sh Demand_And_Capacity_Prod
53+ ./scripts/export_dashboard_image.sh ${{ matrix.env_config.dashboard }} ${{ matrix.env_config.name }}
3954 env :
4055 AWS_REGION : eu-west-2
4156
57+ - name : Upload dashboard export
58+ uses : actions/upload-artifact@v4
59+ with :
60+ name : dashboard-${{ matrix.env_config.name }}
61+ path : dashboard_exports/**/*
62+
63+ generate-report :
64+ runs-on : ubuntu-latest
65+ needs : export-dashboards
66+ environment : reporting
67+
68+ steps :
69+ - name : Checkout code
70+ uses : actions/checkout@v6
71+
72+ - name : Set up Python
73+ uses : actions/setup-python@v6
74+ with :
75+ python-version : " 3.11"
76+
77+ - name : Download all dashboard exports
78+ uses : actions/download-artifact@v4
79+ with :
80+ path : dashboard_exports
81+ pattern : dashboard-*
82+ merge-multiple : true
83+
84+ - name : Generate Combined Report
85+ run : python3 scripts/generate_dashboard_report.py --input dashboard_exports
86+
4287 - name : Upload report as artifact
4388 uses : actions/upload-artifact@v5
4489 with :
4590 name : capacity-report
4691 path : |
47- dashboard_exports/*.html
48- dashboard_exports/*.png
92+ dashboard_exports/**/* .html
93+ dashboard_exports/**/* .png
4994 retention-days : 90
5095
5196 - name : Send to Slack
@@ -54,21 +99,20 @@ jobs:
5499 SLACK_WEBHOOK_URL : ${{ secrets.SLACK_D_AND_C_WEBHOOK }}
55100 run : |
56101 # Get the latest HTML report
57- REPORT_FILE=$(ls -t dashboard_exports/ dashboard_report_*.html | head -1)
102+ REPORT_FILE=$(find dashboard_exports -name " dashboard_report_*.html" | head -n 1)
58103 REPORT_NAME=$(basename "$REPORT_FILE")
59104
60105 # GitHub Actions URL
61106 GITHUB_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
62107
63- # Send Slack notification with simple variables for Workflow Automation
108+ # Send Slack notification
64109 curl -X POST "$SLACK_WEBHOOK_URL" \
65110 -H 'Content-Type: application/json' \
66111 -d @- <<EOF
67112 {
68- "report_title": "📊 Monthly Demand & Capacity Report - EliD - Prod ",
113+ "report_title": "📊 Monthly Demand & Capacity Report - EliD - All Envs ",
69114 "report_period": "Last 8 weeks",
70115 "generated_date": "$(date +'%Y-%m-%d %H:%M UTC')",
71- "widgets_count": "7",
72116 "github_url": "$GITHUB_URL",
73117 "report_name": "$REPORT_NAME"
74118 }
0 commit comments