From b420616cbd1d45f381105539f6e437abd7d9fa7c Mon Sep 17 00:00:00 2001 From: Gautam Botrel Date: Fri, 13 Sep 2024 16:58:46 -0500 Subject: [PATCH] build: test ci --- .github/workflows/slack-notifications.yml | 64 +++++++++++++++++++++-- 1 file changed, 61 insertions(+), 3 deletions(-) diff --git a/.github/workflows/slack-notifications.yml b/.github/workflows/slack-notifications.yml index fb351651b..41d0fc849 100644 --- a/.github/workflows/slack-notifications.yml +++ b/.github/workflows/slack-notifications.yml @@ -38,10 +38,68 @@ jobs: steps: - name: Post to Slack run: | - if [ "${{ inputs.status }}" == "successsuccess" ]; then - payload="{\"channel\":\"team-gnark-build\",\"text\":\"GitHub Action build result: success\",\"blocks\":[{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\":large_green_circle: ${{ inputs.repository }} *${{ inputs.branch }}*\"}},{\"type\":\"context\",\"elements\":[{\"type\":\"plain_text\",\"text\":\"${{ inputs.actor }}\",\"emoji\":true}]}]}" + if [ "${{ inputs.status }}" == "success" ]; then + payload=$(jq -n --arg repository "${{ inputs.repository }}" --arg branch "${{ inputs.branch }}" --arg actor "${{ inputs.actor }}" --arg run_id "${{ inputs.run_id }}" '{ + "channel": "team-gnark-build", + "text": "GitHub Action build result: success", + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": ":white_check_mark: \($repository) *\($branch)*" + } + }, + { + "type": "context", + "elements": [ + { + "type": "plain_text", + "text": "Author: \($actor)", + "emoji": true + } + ] + } + ] + }') else - payload="{\"channel\":\"team-gnark-build\",\"text\":\"GitHub Action build result: failure\",\"blocks\":[{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\":red_circle: ${{ inputs.repository }} *${{ inputs.branch }}*\"}},{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"*Failed Step:* \"}},{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"*Test Failure Details:* ${{ inputs.failures }}\"}},{\"type\":\"context\",\"elements\":[{\"type\":\"plain_text\",\"text\":\"${{ inputs.actor }}\",\"emoji\":true}]}]}" + payload=$(jq -n --arg repository "${{ inputs.repository }}" --arg branch "${{ inputs.branch }}" --arg actor "${{ inputs.actor }}" --arg run_id "${{ inputs.run_id }}" --arg failures "${{ inputs.failures }}" '{ + "channel": "team-gnark-build", + "text": "GitHub Action build result: failure", + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": ":red_circle: \($repository) *\($branch)*" + } + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*Failed Step:* " + } + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*Test Failure Details:* \($failures)" + } + }, + { + "type": "context", + "elements": [ + { + "type": "plain_text", + "text": "Author: \($actor)", + "emoji": true + } + ] + } + ] + }') fi curl -X POST -H 'Content-type: application/json; charset=utf-8' --data "$payload" https://slack.com/api/chat.postMessage -H "Authorization: Bearer ${{ secrets.SLACK_BOT_TOKEN }}" shell: bash \ No newline at end of file