From b69f0b3dd544084b9bb744d5023bb00e7fb30c54 Mon Sep 17 00:00:00 2001 From: Massimiliano Pippi Date: Thu, 25 May 2023 11:26:09 +0200 Subject: [PATCH] track failures on Datadog (#5020) --- .github/workflows/license_compliance.yml | 81 +++++++++--------------- 1 file changed, 29 insertions(+), 52 deletions(-) diff --git a/.github/workflows/license_compliance.yml b/.github/workflows/license_compliance.yml index f0c39487b..1c6246b47 100644 --- a/.github/workflows/license_compliance.yml +++ b/.github/workflows/license_compliance.yml @@ -55,59 +55,36 @@ jobs: if: ${{ always() }} run: echo "${{ steps.license_check_report.outputs.report }}" - - uses: slackapi/slack-github-action@v1.23.0 - if: failure() && github.ref == 'refs/heads/main' - with: - payload: | - { - "blocks": [ - { - "type": "context", - "elements": [ - { - "type": "image", - "image_url": "https://avatars.githubusercontent.com/u/${{ github.actor_id }}?v=4", - "alt_text": "Actor" - }, - { - "type": "mrkdwn", - "text": "**" - } - ] - }, - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "Job ${{ github.job }} in workflow " - } - }, - { - "type": "context", - "elements": [ - { - "type": "mrkdwn", - "text": "Triggered by ${{ github.event_name }} for ${{ github.ref_type }} `${{ github.ref_name }}`" - } - ] - }, - { - "type": "context", - "elements": [ - { - "type": "image", - "image_url": "https://github.githubassets.com/favicons/favicon.png", - "alt_text": "Github logo" - }, - { - "type": "mrkdwn", - "text": " Run " - } - ] - } - ] - } + - name: Calculate alert data + id: calculator + shell: bash + if: (success() || failure()) && github.ref_name == 'main' + run: | + if [ "${{ job.status }}" = "success" ]; then + echo "alert_type=success" >> "$GITHUB_OUTPUT"; + else + echo "alert_type=error" >> "$GITHUB_OUTPUT"; + fi + - name: Send event to Datadog + if: (success() || failure()) && github.ref_name == 'main' + uses: masci/datadog@v1 + with: + api-key: ${{ secrets.CORE_DATADOG_API_KEY }} + api-url: https://api.datadoghq.eu + events: | + - title: "${{ github.workflow }} workflow" + text: "License compliance check failed:\n ${{ steps.license_check_report.outputs.report }}" + alert_type: "${{ steps.calculator.outputs.alert_type }}" + source_type_name: "Github" + host: ${{ github.repository_owner }} + tags: + - "project:${{ github.repository }}" + - "job:${{ github.job }}" + - "run_id:${{ github.run_id }}" + - "workflow:${{ github.workflow }}" + - "branch:${{ github.ref_name }}" + - "url:https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" license_check_vanilla: name: Core dependencies, no extras