diff --git a/.github/workflows/update-automation.yaml b/.github/workflows/update-automation.yaml index d7e8b92..87433cc 100644 --- a/.github/workflows/update-automation.yaml +++ b/.github/workflows/update-automation.yaml @@ -431,8 +431,37 @@ jobs: --dimensions "Repository=${{ env.REPOSITORY }},Workflow=UpdateAutomation" \ --value 1 - handle-failures: - name: Handle Failures + publish-success-metrics: + name: Publish Success Metrics + runs-on: ubuntu-latest + needs: [update-automation, build-and-update-package-locks, generate-oss-attribution, create-pr, send-notification] + environment: update-automation-workflow-env + if: always() && !failure() && !cancelled() + permissions: + id-token: write # Required for OIDC + env: + REPOSITORY: ${{ github.repository }} + AWS_ROLE_TO_ASSUME: ${{ secrets.AWS_ROLE_TO_ASSUME }} + steps: + - name: Use role credentials for metrics + id: aws-creds + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ env.AWS_ROLE_TO_ASSUME }} + aws-region: us-east-1 + - name: Publish success metrics + if: steps.aws-creds.outcome == 'success' + run: | + aws cloudwatch put-metric-data \ + --namespace "GitHub/Workflows" \ + --metric-name "ExecutionsSucceeded" \ + --dimensions "Repository=${{ env.REPOSITORY }},Workflow=UpdateAutomation" \ + --value 1 + + echo "Published metric: ExecutionsSucceeded" + + publish-failure-metrics: + name: Publish Failure Metrics runs-on: ubuntu-latest needs: [update-automation, build-and-update-package-locks, generate-oss-attribution, create-pr, send-notification] environment: update-automation-workflow-env @@ -450,11 +479,13 @@ jobs: with: role-to-assume: ${{ env.AWS_ROLE_TO_ASSUME }} aws-region: us-east-1 - - name: Report failure + - name: Publish failure metrics if: steps.aws-creds.outcome == 'success' run: | aws cloudwatch put-metric-data \ --namespace "GitHub/Workflows" \ --metric-name "ExecutionsFailed" \ --dimensions "Repository=${{ env.REPOSITORY }},Workflow=UpdateAutomation" \ - --value 1 \ No newline at end of file + --value 1 + + echo "Published metric: ExecutionsFailed" \ No newline at end of file