Skip to content

Commit dd366c9

Browse files
committed
add workflow metric
1 parent af0ef57 commit dd366c9

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Workflow Metrics
2+
description: >
3+
Track and upload workflow execution time to CloudWatch
4+
5+
inputs:
6+
workflow-name:
7+
description: >
8+
Name of the workflow
9+
required: true
10+
runs:
11+
using: composite
12+
steps:
13+
- name: Checkout sources
14+
uses: actions/checkout@v2
15+
- name: Configure AWS Credentials
16+
uses: aws-actions/configure-aws-credentials@v4
17+
with:
18+
role-to-assume: arn:aws:iam::886436966712:role/Admin
19+
aws-region: us-west-2
20+
- name: Upload workflow metrics
21+
shell: bash
22+
run: |
23+
duration=$(($(date +%s) - $WORKFLOW_START_TIME))
24+
aws cloudwatch put-metric-data \
25+
--namespace "GitHub/Workflows" \
26+
--metric-data MetricName=Duration,Value=$duration,Unit=Seconds,Dimensions=WorkflowName=${{ inputs.workflow-name }},Repository=${{ github.repository }}

.github/workflows/api-compat-verification.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ on:
99

1010
permissions: { }
1111

12+
env:
13+
WORKFLOW_START_TIME: ${{ github.event.created_at && github.event.created_at || github.run_id }}
14+
1215
jobs:
1316
api-compat-verification:
1417
runs-on: ubuntu-latest
@@ -34,3 +37,8 @@ jobs:
3437
echo "::error ::* Revert the changes which caused the API incompatibility –or–"
3538
echo "::error ::* Add the 'acknowledge-api-break' label to this PR (in rare cases warranting an API breakage)"
3639
exit 1
40+
- name: Upload metrics
41+
if: always()
42+
uses: ./.github/actions/workflow-metrics
43+
with:
44+
workflow-name: 'api-compat-verification'

0 commit comments

Comments
 (0)