This action publishes a single metric to Amazon CloudWatch.
You can use this action to report workflow metrics, such as completed builds, build failures, build times, or any other metric.
Using Amazon CloudWatch, you can then setup a unified dashboard to monitor all your packages, and be alerted when builds fail.
To access AWS from a GitHub Action workflow, consider using configure-aws-credentials. This action simplifies setting AWS credentials correctly.
jobs:
build:
runs-on: ubuntu-latest
name: 'Build'
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Build
run: ./my-build-script.sh
# Make sure the secrets are stored in you repo settings
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2
if: always() # Setup credentials even if the workflow failed
- name: Log Build
# replace TAG by the latest tag in the repository
uses: ros-tooling/action-cloudwatch-metrics@TAG
if: always() # Need to run to log the workflow failure
By default, the action will push a metrics named 'Builds', with a value of 1
if the build succeeds, or 0 otherwise. The metrics dimensions are:
github.event_name
, github.ref
, github.repository
, github.workflow
.
See GitHub actions context documentation for details about those values.
The dimensions of the metric.
Defaults to:
[
{ "Name": "github.event_name", "Value": "${{ github.event_name }}" },
{ "Name": "github.ref", "Value": "${{ github.ref }}" },
{ "Name": "github.repository", "Value": "${{ github.repository }}" }
]
The name of the metric.
Defaults to Builds
.
The value for the metric.
Defaults to ${{ job.status }} == 'success'
.
true
and false
are respectfully transformed to 1.0, and 0.0, in order
to enable boolean values to be passed as metrics.
The namespace for the metric data.
Defaults to ActionCloudWatchMetrics
.
To avoid conflicts with AWS service namespaces, you should not specify a
namespace that begins with AWS/
.