Skip to content

Commit

Permalink
add datadog content-release success notification (#1749)
Browse files Browse the repository at this point in the history
* add datadog content-release success notification

* configure aws credential for Datadog API_key paramater lookup
  • Loading branch information
teeshe authored Oct 19, 2023
1 parent d5f8b9a commit 249c6e5
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/content-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,52 @@ jobs:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

notify-success-datadog:
name: Notify Success (Datadog)
runs-on: [self-hosted, asg]
needs:
- validate-build-status
- deploy

steps:
- name: Checkout
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@e1e17a757e536f70e52b5a12b2e8d1d1c60e04ef # v2.0.0
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-gov-west-1

- name: Get Datadog token from Parameter Store
uses: department-of-veterans-affairs/action-inject-ssm-secrets@d8e6de3bde4dd728c9d732baef58b3c854b8c4bb # latest
with:
ssm_parameter: /dsva-vagov/content-build/GHA_CONTENT_BUILD_DATADOG_API_KEY
env_variable_name: GHA_CONTENT_BUILD_DATADOG_API_KEY

- name: Build JSON object
run: |
jq --null-input '{}' | \
jq '.title = "VA.gov CMS content release was successful"' | \
jq '.text = "VA.gov Content release ${{github.run_id}} completed at \(now|strftime("%Y-%m-%d %H:%M:%S"))! https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}"' | \
jq '.date_happened = now' | \
jq '.aggregation_key = "content release ${{github.run_id}}"' | \
jq '.tags[0] = "project:vagov"' | \
jq '.tags[1] = "repo:content-build"' | \
jq '.tags[2] = "workflow:content-release"' | \
jq '.tags[3] = "env:${{env.DEPLOY_ENV}}"' | \
jq '.tags[5] = "status:${{needs.deploy.result}}"' | \
jq '.tags[6] = "trigger:${{env.BUILD_TRIGGER}}"' | \
jq '.alert_type = "success"' > event.json
- name: Send event to Datadog
run: |
curl -X POST "https://api.ddog-gov.com/api/v1/events" \
-H "Content-Type: text/json" \
-H "DD-API-KEY: ${{ env.GHA_CONTENT_BUILD_DATADOG_API_KEY }}" \
-d @- < event.json
notify-failure:
name: Notify Failure
runs-on: [self-hosted, asg]
Expand Down

0 comments on commit 249c6e5

Please sign in to comment.