Publish Job Success Metric to CloudWatch #4588
This file contains 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: 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 |