Monthly Demand and Capacity Report #10
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: 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: | |
| generate-report: | |
| runs-on: ubuntu-latest | |
| environment: reporting | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| # ---------------------------------------------------------------- | |
| # 1. Export PROD | |
| # ---------------------------------------------------------------- | |
| - name: "Configure AWS Credentials (Prod)" | |
| uses: aws-actions/configure-aws-credentials@v5 | |
| with: | |
| role-to-assume: arn:aws:iam::${{ secrets.AWS_PROD_ACCOUNT_ID }}:role/service-roles/github-actions-api-deployment-role | |
| aws-region: eu-west-2 | |
| - name: Export Dashboard (Prod) | |
| run: | | |
| chmod +x scripts/export_dashboard_image.sh | |
| ./scripts/export_dashboard_image.sh Demand_And_Capacity_Prod Prod | |
| env: | |
| AWS_REGION: eu-west-2 | |
| # ---------------------------------------------------------------- | |
| # 2. Export PREPROD | |
| # ---------------------------------------------------------------- | |
| - name: "Configure AWS Credentials (Preprod)" | |
| uses: aws-actions/configure-aws-credentials@v5 | |
| with: | |
| role-to-assume: arn:aws:iam::${{ secrets.AWS_PREPROD_ACCOUNT_ID }}:role/service-roles/github-actions-api-deployment-role | |
| aws-region: eu-west-2 | |
| - name: Export Dashboard (Preprod) | |
| run: ./scripts/export_dashboard_image.sh Demand_And_Capacity_Preprod Preprod | |
| env: | |
| AWS_REGION: eu-west-2 | |
| # ---------------------------------------------------------------- | |
| # 3. Export TEST | |
| # ---------------------------------------------------------------- | |
| - name: "Configure AWS Credentials (Test)" | |
| uses: aws-actions/configure-aws-credentials@v5 | |
| with: | |
| role-to-assume: arn:aws:iam::${{ secrets.AWS_TEST_ACCOUNT_ID }}:role/service-roles/github-actions-api-deployment-role | |
| aws-region: eu-west-2 | |
| - name: Export Dashboard (Test) | |
| run: ./scripts/export_dashboard_image.sh Demand_And_Capacity_Test Test | |
| env: | |
| AWS_REGION: eu-west-2 | |
| # ---------------------------------------------------------------- | |
| # 4. Export DEV | |
| # ---------------------------------------------------------------- | |
| - name: "Configure AWS Credentials (Dev)" | |
| uses: aws-actions/configure-aws-credentials@v5 | |
| with: | |
| role-to-assume: arn:aws:iam::${{ secrets.AWS_DEV_ACCOUNT_ID }}:role/service-roles/github-actions-api-deployment-role | |
| aws-region: eu-west-2 | |
| - name: Export Dashboard (Dev) | |
| run: ./scripts/export_dashboard_image.sh Demand_And_Capacity_Dev Dev | |
| env: | |
| AWS_REGION: eu-west-2 | |
| # ---------------------------------------------------------------- | |
| # Generate & Notify | |
| # ---------------------------------------------------------------- | |
| - name: Generate Combined Report | |
| run: python3 scripts/generate_dashboard_report.py --input dashboard_exports | |
| - name: Upload report as artifact | |
| uses: actions/upload-artifact@v4 | |
| 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 |