From 93617478ad20b9b14eaa6b0c2d75605bc5ffeb02 Mon Sep 17 00:00:00 2001 From: Gautam Botrel Date: Fri, 13 Sep 2024 15:40:08 -0500 Subject: [PATCH] build: ci test --- .github/workflows/slack-notifications.yml | 80 ++++------------------- 1 file changed, 13 insertions(+), 67 deletions(-) diff --git a/.github/workflows/slack-notifications.yml b/.github/workflows/slack-notifications.yml index ac0392fd4..7dc5dbd23 100644 --- a/.github/workflows/slack-notifications.yml +++ b/.github/workflows/slack-notifications.yml @@ -40,74 +40,20 @@ jobs: notify_slack: runs-on: ubuntu-latest steps: - - name: Post to a Slack channel - id: slack + - name: Set Slack message payload + id: set_payload + run: | + if [ "${{ inputs.status }}" == "success" ]; then + echo "::set-output name=payload::{\"text\":\"GitHub Action build result: success\",\"blocks\":[{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\":white_check_mark: *Workflow Succeeded*\"}},{\"type\":\"section\",\"fields\":[{\"type\":\"mrkdwn\",\"text\":\"*Actor:*\n${{ inputs.actor }}\"},{\"type\":\"mrkdwn\",\"text\":\"*Repository:*\n${{ inputs.repository }}\"},{\"type\":\"mrkdwn\",\"text\":\"*PR Title:*\n${{ inputs.pr_title }}\"},{\"type\":\"mrkdwn\",\"text\":\"*Branch:*\n${{ inputs.branch }}\"}]},{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"*View Run:* \"}}]}" + else + echo "::set-output name=payload::{\"text\":\"GitHub Action build result: failure\",\"blocks\":[{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\":x: *Workflow Failed*\"}},{\"type\":\"section\",\"fields\":[{\"type\":\"mrkdwn\",\"text\":\"*Actor:*\n${{ inputs.actor }}\"},{\"type\":\"mrkdwn\",\"text\":\"*Repository:*\n${{ inputs.repository }}\"},{\"type\":\"mrkdwn\",\"text\":\"*PR Title:*\n${{ inputs.pr_title }}\"},{\"type\":\"mrkdwn\",\"text\":\"*Branch:*\n${{ inputs.branch }}\"}]},{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"*Failed Step:* \"}},{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"*Test Failure Details:* \n${{ inputs.failures }}\"}}]}" + fi + shell: bash + + - name: Post to Slack uses: slackapi/slack-github-action@v1.27.0 with: channel-id: 'team-gnark-build' - payload: | - { - "text": "GitHub Action Notification", - "blocks": [ - { - "type": "header", - "text": { - "type": "plain_text", - "text": "GitHub Action Notification", - "emoji": true - } - }, - { - "type": "section", - "fields": [ - { - "type": "mrkdwn", - "text": "*Status:*\n${{ inputs.status }}" - }, - { - "type": "mrkdwn", - "text": "*Branch:*\n${{ inputs.branch }}" - }, - { - "type": "mrkdwn", - "text": "*Actor:*\n${{ inputs.actor }}" - }, - { - "type": "mrkdwn", - "text": "*Repository:*\n${{ inputs.repository }}" - } - ] - }, - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*PR Title:*\n${{ inputs.pr_title || 'N/A' }}" - } - }, - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*Run ID:*\n${{ inputs.run_id }}" - } - }, - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*Failures:*\n${{ inputs.failures || 'None' }}" - } - }, - { - "type": "context", - "elements": [ - { - "type": "mrkdwn", - "text": "View details: <${{ github.event.pull_request.html_url || github.event.head_commit.url }}|Click here>" - } - ] - } - ] - } + payload: ${{ steps.set_payload.outputs.payload }} + env: SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} \ No newline at end of file