From f7fed1aa25913acfed663f00aeace13a1bb15440 Mon Sep 17 00:00:00 2001 From: Tolase Akinwale Date: Tue, 17 Oct 2023 20:31:03 -0500 Subject: [PATCH] add datadog content-release success notification --- .github/workflows/content-release.yml | 36 +++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/.github/workflows/content-release.yml b/.github/workflows/content-release.yml index 4d0810783f..54ccb76398 100644 --- a/.github/workflows/content-release.yml +++ b/.github/workflows/content-release.yml @@ -479,6 +479,42 @@ 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: 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]