From 432a2e9c5a14f44ba96eac4d86b0b9e4a560a939 Mon Sep 17 00:00:00 2001 From: Feiyang Liu Date: Fri, 26 Sep 2025 11:37:14 +0200 Subject: [PATCH 1/5] Refactor execution metrics reporting to handle success and failure cases dynamically --- .github/workflows/update-automation.yaml | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/update-automation.yaml b/.github/workflows/update-automation.yaml index d7e8b92..0eb331d 100644 --- a/.github/workflows/update-automation.yaml +++ b/.github/workflows/update-automation.yaml @@ -431,12 +431,12 @@ jobs: --dimensions "Repository=${{ env.REPOSITORY }},Workflow=UpdateAutomation" \ --value 1 - handle-failures: - name: Handle Failures + publish-execution-metrics: + name: Publish Execution 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: failure() + if: always() permissions: id-token: write # Required for OIDC env: @@ -450,11 +450,19 @@ jobs: with: role-to-assume: ${{ env.AWS_ROLE_TO_ASSUME }} aws-region: us-east-1 - - name: Report failure + - name: Publish execution metrics if: steps.aws-creds.outcome == 'success' run: | + if [ "${{ needs.update-automation.result }}" = "failure" ] || [ "${{ needs.build-and-update-package-locks.result }}" = "failure" ] || [ "${{ needs.generate-oss-attribution.result }}" = "failure" ] || [ "${{ needs.create-pr.result }}" = "failure" ] || [ "${{ needs.send-notification.result }}" = "failure" ]; then + METRIC_NAME="ExecutionsFailed" + else + METRIC_NAME="ExecutionsSucceeded" + fi + aws cloudwatch put-metric-data \ --namespace "GitHub/Workflows" \ - --metric-name "ExecutionsFailed" \ + --metric-name "$METRIC_NAME" \ --dimensions "Repository=${{ env.REPOSITORY }},Workflow=UpdateAutomation" \ - --value 1 \ No newline at end of file + --value 1 + + echo "Published metric: $METRIC_NAME" \ No newline at end of file From 55cee0613ba3f3db904ad4455782282aafc89323 Mon Sep 17 00:00:00 2001 From: Feiyang Liu Date: Mon, 29 Sep 2025 14:59:57 +0200 Subject: [PATCH 2/5] Refactor execution metrics to separate success and failure metrics publishing --- .github/workflows/update-automation.yaml | 46 ++++++++++++++++++------ 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/.github/workflows/update-automation.yaml b/.github/workflows/update-automation.yaml index 0eb331d..c038c8a 100644 --- a/.github/workflows/update-automation.yaml +++ b/.github/workflows/update-automation.yaml @@ -431,12 +431,12 @@ jobs: --dimensions "Repository=${{ env.REPOSITORY }},Workflow=UpdateAutomation" \ --value 1 - publish-execution-metrics: - name: Publish Execution Metrics + 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() + if: success () permissions: id-token: write # Required for OIDC env: @@ -450,19 +450,43 @@ jobs: with: role-to-assume: ${{ env.AWS_ROLE_TO_ASSUME }} aws-region: us-east-1 - - name: Publish execution metrics + - name: Publish success metrics if: steps.aws-creds.outcome == 'success' run: | - if [ "${{ needs.update-automation.result }}" = "failure" ] || [ "${{ needs.build-and-update-package-locks.result }}" = "failure" ] || [ "${{ needs.generate-oss-attribution.result }}" = "failure" ] || [ "${{ needs.create-pr.result }}" = "failure" ] || [ "${{ needs.send-notification.result }}" = "failure" ]; then - METRIC_NAME="ExecutionsFailed" - else - METRIC_NAME="ExecutionsSucceeded" - fi + 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 + if: failure () + 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 + continue-on-error: ${{ env.REPOSITORY != 'aws/code-editor' }} + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ env.AWS_ROLE_TO_ASSUME }} + aws-region: us-east-1 + - name: Publish failure metrics + if: steps.aws-creds.outcome == 'success' + run: | aws cloudwatch put-metric-data \ --namespace "GitHub/Workflows" \ - --metric-name "$METRIC_NAME" \ + --metric-name "ExecutionsFailed" \ --dimensions "Repository=${{ env.REPOSITORY }},Workflow=UpdateAutomation" \ --value 1 - echo "Published metric: $METRIC_NAME" \ No newline at end of file + echo "Published metric: ExecutionsFailed" \ No newline at end of file From 7884eb54947391d80bc2bfd25cf696bc9225f666 Mon Sep 17 00:00:00 2001 From: Feiyang Liu Date: Mon, 29 Sep 2025 15:05:55 +0200 Subject: [PATCH 3/5] Fix syntax for success and failure conditions in update-automation workflow --- .github/workflows/update-automation.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/update-automation.yaml b/.github/workflows/update-automation.yaml index c038c8a..c2c928c 100644 --- a/.github/workflows/update-automation.yaml +++ b/.github/workflows/update-automation.yaml @@ -436,7 +436,7 @@ jobs: 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: success () + if: success() permissions: id-token: write # Required for OIDC env: @@ -466,7 +466,7 @@ jobs: 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: failure () + if: failure() permissions: id-token: write # Required for OIDC env: From 314ed21226f9d6a840c79281fb6711efb8b4cf29 Mon Sep 17 00:00:00 2001 From: Feiyang Liu Date: Tue, 30 Sep 2025 13:34:32 +0200 Subject: [PATCH 4/5] Remove conditional continue-on-error for AWS credentials step in update-automation workflow --- .github/workflows/update-automation.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/update-automation.yaml b/.github/workflows/update-automation.yaml index c2c928c..1e1c9be 100644 --- a/.github/workflows/update-automation.yaml +++ b/.github/workflows/update-automation.yaml @@ -445,7 +445,6 @@ jobs: steps: - name: Use role credentials for metrics id: aws-creds - continue-on-error: ${{ env.REPOSITORY != 'aws/code-editor' }} uses: aws-actions/configure-aws-credentials@v4 with: role-to-assume: ${{ env.AWS_ROLE_TO_ASSUME }} From 2263f495a0289b246b31a6e93380b85ca73ab292 Mon Sep 17 00:00:00 2001 From: Feiyang Liu Date: Tue, 30 Sep 2025 15:24:46 +0200 Subject: [PATCH 5/5] Update if conditional of success metrics to include more scenarios --- .github/workflows/update-automation.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-automation.yaml b/.github/workflows/update-automation.yaml index 1e1c9be..87433cc 100644 --- a/.github/workflows/update-automation.yaml +++ b/.github/workflows/update-automation.yaml @@ -436,7 +436,7 @@ jobs: 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: success() + if: always() && !failure() && !cancelled() permissions: id-token: write # Required for OIDC env: