Skip to content

Monthly Demand and Capacity Report #15

Monthly Demand and Capacity Report

Monthly Demand and Capacity Report #15

name: Monthly Demand and Capacity Report
on:
# Run monthly on the 1st at 9 AM UTC
schedule:
- cron: "0 9 1 * *"
# Allow manual trigger
workflow_dispatch:
permissions:
contents: read
id-token: write # Required for AWS OIDC authentication
jobs:
export-dashboards:
runs-on: ubuntu-latest
environment: reporting
strategy:
matrix:
env_config:
- name: Prod
dashboard: Demand_And_Capacity_Prod
account_secret: AWS_PROD_ACCOUNT_ID
- name: Preprod
dashboard: Demand_And_Capacity_Preprod
account_secret: AWS_PREPROD_ACCOUNT_ID
- name: Test
dashboard: Demand_And_Capacity_Test
account_secret: AWS_TEST_ACCOUNT_ID
- name: Dev
dashboard: Demand_And_Capacity_Dev
account_secret: AWS_DEV_ACCOUNT_ID
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.11"
- name: Configure AWS Credentials (${{ matrix.env_config.name }})
uses: aws-actions/configure-aws-credentials@v6
with:
role-to-assume: arn:aws:iam::${{ secrets[matrix.env_config.account_secret] }}:role/service-roles/github-actions-api-deployment-role
aws-region: eu-west-2
- name: Export Dashboard (${{ matrix.env_config.name }})
run: |
chmod +x scripts/export_dashboard_image.sh
./scripts/export_dashboard_image.sh ${{ matrix.env_config.dashboard }} ${{ matrix.env_config.name }}
env:
AWS_REGION: eu-west-2
- name: Upload dashboard export
uses: actions/upload-artifact@v6
with:
name: dashboard-${{ matrix.env_config.name }}
path: dashboard_exports/**/*
generate-report:
runs-on: ubuntu-latest
needs: export-dashboards
environment: reporting
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.11"
- name: Download all dashboard exports
uses: actions/download-artifact@v7
with:
path: dashboard_exports
pattern: dashboard-*
merge-multiple: true
- name: Generate Combined Report
run: python3 scripts/generate_dashboard_report.py --input dashboard_exports
- name: Upload report as artifact
uses: actions/upload-artifact@v6
with:
name: capacity-report
path: |
dashboard_exports/**/*.html
dashboard_exports/**/*.png
retention-days: 90
- name: Send to Slack
if: success()
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_D_AND_C_WEBHOOK }}
run: |
# Get the latest HTML report
REPORT_FILE=$(find dashboard_exports -name "dashboard_report_*.html" | head -n 1)
REPORT_NAME=$(basename "$REPORT_FILE")
# GitHub Actions URL
GITHUB_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
# Send Slack notification
curl -X POST "$SLACK_WEBHOOK_URL" \
-H 'Content-Type: application/json' \
-d @- <<EOF
{
"report_title": "📊 Monthly Demand & Capacity Report - EliD - All Envs",
"report_period": "Last 8 weeks",
"generated_date": "$(date +'%Y-%m-%d %H:%M UTC')",
"github_url": "$GITHUB_URL",
"report_name": "$REPORT_NAME"
}
EOF