Skip to content

Publish Job Success Metric to CloudWatch #4365

Publish Job Success Metric to CloudWatch

Publish Job Success Metric to CloudWatch #4365

name: Publish Job Success Metric to CloudWatch
on:
workflow_run:
workflows: "*"
types:
- completed
branches:
- master
permissions:
id-token: write
contents: read
jobs:
publish-job-success-to-cloudwatch:
if: ${{ github.event.workflow_run.event == 'schedule' }}
runs-on: ubuntu-latest
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::185921645874:role/github-actions-djl-serving
aws-region: us-west-2
- name: Publish Job Success Metric
env:
WORKFLOW_NAME: ${{ github.event.workflow_run.display_title }}
REPO_NAME: ${{ github.event.workflow_run.repository.name }}
CONCLUSION: ${{ github.event.workflow_run.conclusion }}
run: |
workflow_name=$(echo "$WORKFLOW_NAME" | tr -d ' ')
metric_name="${REPO_NAME}-${workflow_name}-Failure"
failedBuild=$([ "$CONCLUSION" == "success" ]; echo $?)
aws cloudwatch put-metric-data --namespace GithubCI \
--metric-name "$metric_name" \
--value $failedBuild \
--unit Count