From 437a4fb165eda95d75344279c7a2296979a294f8 Mon Sep 17 00:00:00 2001 From: Pankaj Mouriya Date: Wed, 8 Jan 2025 06:01:22 +0530 Subject: [PATCH 1/4] chore(ci,release): update slack message --- .github/workflows/ci.yml | 88 +++++++++++++++++++++++++++- .github/workflows/release.yml | 104 +++++++++++++++++++++++++++++++++- 2 files changed, 188 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3462d036..14100e40 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,7 +59,49 @@ jobs: with: slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL_NOTIFY_PUBLIC_SHARED_ACTIONS }} status: success - success-message: ":white_check_mark: ${{ github.workflow }} workflow successfully ran within ${{ github.repository }}" + payload: | + { + "text": "Completely custom Slack message for CI", + "blocks": [ + { + "type": "header", + "text": { + "type": "plain_text", + "emoji": true, + "text": "CI Workflow Success" + } + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Repository:*\n<${{ github.server_url }}/${{ github.repository }}|${{ github.repository }}>" + }, + { + "type": "mrkdwn", + "text": "*Branch:*\n<${{ github.server_url }}/${{ github.repository }}/tree/${{ github.head_ref || steps.slack-variables.outputs.fallback-branch-name }}|${{ github.head_ref || steps.slack-variables.outputs.fallback-branch-name }}>" + }, + { + "type": "mrkdwn", + "text": "*Workflow Run:*\n<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ github.run_number }}>" + }, + { + "type": "mrkdwn", + "text": "*TriggeredByCommit:*\n<${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}>" + }, + { + "type": "mrkdwn", + "text": "*Triggered By:*\n${{ github.actor }}" + }, + { + "type": "mrkdwn", + "text": "*Event Name:*\n${{ github.event_name }}" + } + ] + } + ] + } # Failure Notification - name: Send Failure Slack alert @@ -68,4 +110,46 @@ jobs: with: slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL_ALERT_PUBLIC_SHARED_ACTIONS }} status: failure - failure-message: ":x: This is a *failure* notification from ${{ github.repository }} for workflow ${{ github.workflow }}" \ No newline at end of file + payload: | + { + "text": "Completely custom Slack message for CI", + "blocks": [ + { + "type": "header", + "text": { + "type": "plain_text", + "emoji": true, + "text": "CI Workflow Failure" + } + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Repository:*\n<${{ github.server_url }}/${{ github.repository }}|${{ github.repository }}>" + }, + { + "type": "mrkdwn", + "text": "*Branch:*\n<${{ github.server_url }}/${{ github.repository }}/tree/${{ github.head_ref || steps.slack-variables.outputs.fallback-branch-name }}|${{ github.head_ref || steps.slack-variables.outputs.fallback-branch-name }}>" + }, + { + "type": "mrkdwn", + "text": "*Workflow Run:*\n<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ github.run_number }}>" + }, + { + "type": "mrkdwn", + "text": "*TriggeredByCommit:*\n<${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}>" + }, + { + "type": "mrkdwn", + "text": "*Triggered By:*\n${{ github.actor }}" + }, + { + "type": "mrkdwn", + "text": "*Event Name:*\n${{ github.event_name }}" + } + ] + } + ] + } \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e900cd08..8c09fbf7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -78,7 +78,57 @@ jobs: with: slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL_NOTIFY_PUBLIC_SHARED_ACTIONS }} status: success - success-message: ":white_check_mark: ${{ github.workflow }} workflow successfully ran within ${{ github.repository }}" + payload: | + { + "text": "Completely custom Slack message for release", + "blocks": [ + { + "type": "header", + "text": { + "type": "plain_text", + "emoji": true, + "text": "Release Workflow Success" + } + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Repository:*\n<${{ github.server_url }}/${{ github.repository }}|${{ github.repository }}>" + }, + { + "type": "mrkdwn", + "text": "*Branch:*\n<${{ github.server_url }}/${{ github.repository }}/tree/${{ github.head_ref || steps.slack-variables.outputs.fallback-branch-name }}|${{ github.head_ref || steps.slack-variables.outputs.fallback-branch-name }}>" + }, + { + "type": "mrkdwn", + "text": "*Workflow Run:*\n<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ github.run_number }}>" + }, + { + "type": "mrkdwn", + "text": "*TriggeredByCommit:*\n<${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}>" + }, + { + "type": "mrkdwn", + "text": "*Release Commit:*\n<${{ github.server_url }}/${{ github.repository }}/commit/${{ needs.release.outputs.release_commit }}|${{ needs.release.outputs.release_commit }}>" + }, + { + "type": "mrkdwn", + "text": "*Triggered By:*\n${{ github.actor }}" + }, + { + "type": "mrkdwn", + "text": "*Commit Author:*\n${{ github.event.head_commit.author.name }}" + }, + { + "type": "mrkdwn", + "text": "*Event Name:*\n${{ github.event_name }}" + } + ] + } + ] + } # Failure Notification - name: Send Failure Notification @@ -87,4 +137,54 @@ jobs: with: slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL_ALERT_PUBLIC_SHARED_ACTIONS }} status: failure - failure-message: ":x: This is a *failure* notification from ${{ github.repository }} for workflow ${{ github.workflow }}" \ No newline at end of file + payload: | + { + "text": "Completely custom Slack message for release", + "blocks": [ + { + "type": "header", + "text": { + "type": "plain_text", + "emoji": true, + "text": "Release Workflow Failure" + } + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Repository:*\n<${{ github.server_url }}/${{ github.repository }}|${{ github.repository }}>" + }, + { + "type": "mrkdwn", + "text": "*Branch:*\n<${{ github.server_url }}/${{ github.repository }}/tree/${{ github.head_ref || steps.slack-variables.outputs.fallback-branch-name }}|${{ github.head_ref || steps.slack-variables.outputs.fallback-branch-name }}>" + }, + { + "type": "mrkdwn", + "text": "*Workflow Run:*\n<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ github.run_number }}>" + }, + { + "type": "mrkdwn", + "text": "*TriggeredByCommit:*\n<${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}>" + }, + { + "type": "mrkdwn", + "text": "*Release Commit:*\n<${{ github.server_url }}/${{ github.repository }}/commit/${{ needs.release.outputs.release_commit }}|${{ needs.release.outputs.release_commit }}>" + }, + { + "type": "mrkdwn", + "text": "*Triggered By:*\n${{ github.actor }}" + }, + { + "type": "mrkdwn", + "text": "*Commit Author:*\n${{ github.event.head_commit.author.name }}" + }, + { + "type": "mrkdwn", + "text": "*Event Name:*\n${{ github.event_name }}" + } + ] + } + ] + } \ No newline at end of file From 027bbbe96914e78b7672cbb2f254ff4aac708e6f Mon Sep 17 00:00:00 2001 From: Pankaj Mouriya Date: Wed, 8 Jan 2025 06:03:37 +0530 Subject: [PATCH 2/4] chore(ci): test slack message --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 14100e40..60fe778e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,7 +47,7 @@ jobs: name: Slack Notification runs-on: ubuntu-latest needs: setup-and-lint - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} + # if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} steps: - name: Checkout repository uses: actions/checkout@v4 From 705e585f2df1fc0b42b612228c66c75a0c7d61a9 Mon Sep 17 00:00:00 2001 From: Pankaj Mouriya Date: Wed, 8 Jan 2025 06:03:53 +0530 Subject: [PATCH 3/4] chore(ci): test slack message --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 60fe778e..14100e40 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,7 +47,7 @@ jobs: name: Slack Notification runs-on: ubuntu-latest needs: setup-and-lint - # if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} steps: - name: Checkout repository uses: actions/checkout@v4 From 4ee217a010f4d13976cdce9ac962d0e438d051fd Mon Sep 17 00:00:00 2001 From: Pankaj Mouriya Date: Thu, 9 Jan 2025 16:20:37 +0530 Subject: [PATCH 4/4] fix(ci,release): update slack commit message --- .github/workflows/ci.yml | 16 ++++++++++++---- .github/workflows/release.yml | 17 ++++------------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 14100e40..48f9c3f1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -80,7 +80,7 @@ jobs: }, { "type": "mrkdwn", - "text": "*Branch:*\n<${{ github.server_url }}/${{ github.repository }}/tree/${{ github.head_ref || steps.slack-variables.outputs.fallback-branch-name }}|${{ github.head_ref || steps.slack-variables.outputs.fallback-branch-name }}>" + "text": "*Branch:*\n<${{ github.server_url }}/${{ github.repository }}/tree/${{ github.ref_name }}|${{ github.ref_name }}>" }, { "type": "mrkdwn", @@ -88,12 +88,16 @@ jobs: }, { "type": "mrkdwn", - "text": "*TriggeredByCommit:*\n<${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}>" + "text": "*TriggeredByCommit:*\n<${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}|${{ steps.slack-variables.outputs.short-commit-hash }}>" }, { "type": "mrkdwn", "text": "*Triggered By:*\n${{ github.actor }}" }, + { + "type": "mrkdwn", + "text": "*Commit Author:*\n${{ github.event.head_commit.author.name }}" + }, { "type": "mrkdwn", "text": "*Event Name:*\n${{ github.event_name }}" @@ -131,7 +135,7 @@ jobs: }, { "type": "mrkdwn", - "text": "*Branch:*\n<${{ github.server_url }}/${{ github.repository }}/tree/${{ github.head_ref || steps.slack-variables.outputs.fallback-branch-name }}|${{ github.head_ref || steps.slack-variables.outputs.fallback-branch-name }}>" + "text": "*Branch:*\n<${{ github.server_url }}/${{ github.repository }}/tree/${{ github.ref_name }}|${{ github.ref_name }}>" }, { "type": "mrkdwn", @@ -139,12 +143,16 @@ jobs: }, { "type": "mrkdwn", - "text": "*TriggeredByCommit:*\n<${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}>" + "text": "*TriggeredByCommit:*\n<${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}|${{ steps.slack-variables.outputs.short-commit-hash }}>" }, { "type": "mrkdwn", "text": "*Triggered By:*\n${{ github.actor }}" }, + { + "type": "mrkdwn", + "text": "*Commit Author:*\n${{ github.event.head_commit.author.name }}" + }, { "type": "mrkdwn", "text": "*Event Name:*\n${{ github.event_name }}" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8c09fbf7..bf455c25 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -44,7 +44,6 @@ jobs: - name: Setup Git Config shell: bash run: | - git checkout ${{ github.head_ref }} git config --local user.name "kong-security-bot" git config --local user.email "117922193+kong-security-bot@users.noreply.github.com" @@ -99,7 +98,7 @@ jobs: }, { "type": "mrkdwn", - "text": "*Branch:*\n<${{ github.server_url }}/${{ github.repository }}/tree/${{ github.head_ref || steps.slack-variables.outputs.fallback-branch-name }}|${{ github.head_ref || steps.slack-variables.outputs.fallback-branch-name }}>" + "text": "*Branch:*\n<${{ github.server_url }}/${{ github.repository }}/tree/${{ github.ref_name }}|${{ github.ref_name }}>" }, { "type": "mrkdwn", @@ -107,7 +106,7 @@ jobs: }, { "type": "mrkdwn", - "text": "*TriggeredByCommit:*\n<${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}>" + "text": "*TriggeredByCommit:*\n<${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}|${{ github.sha }}>" }, { "type": "mrkdwn", @@ -117,10 +116,6 @@ jobs: "type": "mrkdwn", "text": "*Triggered By:*\n${{ github.actor }}" }, - { - "type": "mrkdwn", - "text": "*Commit Author:*\n${{ github.event.head_commit.author.name }}" - }, { "type": "mrkdwn", "text": "*Event Name:*\n${{ github.event_name }}" @@ -158,7 +153,7 @@ jobs: }, { "type": "mrkdwn", - "text": "*Branch:*\n<${{ github.server_url }}/${{ github.repository }}/tree/${{ github.head_ref || steps.slack-variables.outputs.fallback-branch-name }}|${{ github.head_ref || steps.slack-variables.outputs.fallback-branch-name }}>" + "text": "*Branch:*\n<${{ github.server_url }}/${{ github.repository }}/tree/${{ github.ref_name }}|${{ github.ref_name }}>" }, { "type": "mrkdwn", @@ -166,7 +161,7 @@ jobs: }, { "type": "mrkdwn", - "text": "*TriggeredByCommit:*\n<${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}>" + "text": "*TriggeredByCommit:*\n<${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}|${{ github.sha }}>" }, { "type": "mrkdwn", @@ -176,10 +171,6 @@ jobs: "type": "mrkdwn", "text": "*Triggered By:*\n${{ github.actor }}" }, - { - "type": "mrkdwn", - "text": "*Commit Author:*\n${{ github.event.head_commit.author.name }}" - }, { "type": "mrkdwn", "text": "*Event Name:*\n${{ github.event_name }}"